Results 1 to 6 of 6

Thread: unassigned local variable[Resolved]

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    unassigned local variable[Resolved]

    Why I keep getting this error whenever I declare new instance of data.ole classes ??

    " Class1.cs(184): Use of unassigned local variable 'adoReader' "
    Last edited by Pirate; Mar 22nd, 2003 at 12:43 PM.

  2. #2

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: unassigned local variable

    here's what I did :

    Code:
    System.Data.OleDb.OleDbCommandBuilder builder;
    It looks right . Doesn't it ?

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    C# enforces definite assignment, meaning, all variables must be assigned a value before accessing one of the objects members. For example:

    Code:
    int i;    // should be int i = 0;
    
    // this will throw an error
    Console.WriteLine(i.ToString());

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    That's right . But if I don't want to intialize a variable . still possible ?
    Thanks

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    assign it null
    Dont gain the world and lose your soul

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by DevGrp
    assign it null
    Good idea
    Thanks guys !

Posting Permissions

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



Click Here to Expand Forum to Full Width