Results 1 to 3 of 3

Thread: fixed statement

  1. #1
    AndersonDiaz is offline Senior Member
    Join Date
    Dec 2009
    Posts
    311
    Rep Power
    3

    Default fixed statement

    Use of fixed statement in C sharp

    I am learning various programming language like C#, java, Visual Basic. Right now I am learning C#. I want to know how to use of fixed statement is in C#. I have referred different programming book but did not get suitable details. Please give me some details about the use of fixed statement. If you have any C# program for fixed statement then also let me know that. Thanks in advance.

  2. #2
    TaylorRyan is offline Senior Member
    Join Date
    Dec 2009
    Posts
    307
    Rep Power
    3

    Default

    The fixed statement of C# is utilized to check the variable repositioning using garbage collector. In C# the fixed statement is permitted only in unsafe context. The fixed statements are also utilized for the initialization of pointers. And for that you just require to make nesting of fixed statements. Observe following example:

    fixed (int* pl1 = &pl.xa)

    fixed (double* pl2 = &array[6]) // do something with pl1 and pl2
    Last edited by nitesh14; 02-06-2010 at 03:21 PM.

  3. #3
    ThomasBarnes is offline Senior Member
    Join Date
    Dec 2009
    Posts
    303
    Rep Power
    3

    Default

    Try to understand following code which will show you the use of fixed statement in C#.

    class Test
    {
    static string name = "xx";
    unsafe static void F(char* p) {
    for (int i = 0; p[i] != '\0'; ++i)
    Console.WriteLine(p[i]);
    }
    static void Main() {
    unsafe {
    fixed (char* p = name) F(p);
    fixed (char* p = "xx") F(p);
    }
    }
    }
    Last edited by nitesh14; 02-06-2010 at 03:21 PM.

Similar Threads

  1. Statement in visual basic
    By PowellParker in forum Programming
    Replies: 1
    Last Post: 05-27-2010, 02:29 PM
  2. Risk of social statement over internet
    By Garcíarobine in forum General Internet Terms
    Replies: 1
    Last Post: 04-07-2010, 03:00 PM
  3. Print a Dynamic SQL Statement
    By BakerJones in forum Programming
    Replies: 0
    Last Post: 03-11-2010, 05:15 PM
  4. Lock Statement
    By Garcíarobine in forum Programming
    Replies: 2
    Last Post: 02-03-2010, 12:59 PM
  5. statement in java program
    By PetersonClark in forum Programming
    Replies: 1
    Last Post: 01-27-2010, 02:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48