Halkatla
asked on
Use of unassigned local variable
Hello to all experts! :o)
In a project, I have created my own class to make siblings-objects. A sibling-object shall only be created if the childArray has elements. Why do I get the error "Use of unassigned local variable children" in the writeline-line?
public static void Main(){
string[] childArray = {"child 1", "child 2"};
wSiblings children;
if (childArray.Length > 0){
children = new wSiblings();
children.Id = 1;
}
System.Console.WriteLine(c hildren.Id );
}
What am I missing or have forgotten about c#-programming?
//Halkatla
In a project, I have created my own class to make siblings-objects. A sibling-object shall only be created if the childArray has elements. Why do I get the error "Use of unassigned local variable children" in the writeline-line?
public static void Main(){
string[] childArray = {"child 1", "child 2"};
wSiblings children;
if (childArray.Length > 0){
children = new wSiblings();
children.Id = 1;
}
System.Console.WriteLine(c
}
What am I missing or have forgotten about c#-programming?
//Halkatla
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.