Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing dataset by reference
Message
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01538045
Message ID:
01538070
Views:
28
>>Hi,
>>
>>Here is a segment of code:
>>
>>
>>DataSet ds = new DataSet();
>>MyClass.MyMethod( ds );
>>
>>if (ds =!null)
>>{
>>    // Error message. Since ds is null.  But why the above ds =! null does not catch it? 
>>}
>>
>>MyClass.MyMethod( DataSet ds)
>>{
>>     // for testing
>>     ds = null;
>>}
>>
>>
>>Why does the line ds =! null does not catch that the ds is null?
>>
>>I also tried to declare the parameter ds as Out but it does not work either.
>
>To sum up what others have already said :-} :
            DataSet ds ;
>            // bool b = ds != null;  //Won't compile - use of unassigned variable.
>            ds = null;
>            bool b = ds != null; //false;
>            ds = new DataSet();
>            b = ds != null;  //true
>
>           //Using 'out' param
>            DataSet ds2;
>            b = GetDataSet(out ds2);
where:
      bool GetDataSet(out DataSet ds)
>        {
>            ds = new DataSet();
>            return true;
>        }
Also 'ds = !null' is not valid syntax

Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform