i am getting an error use of unassigned local variable 'j'.......in the following code .....could you help?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace structure
{
class Program
{
struct jeetu // no semi colon
{
public string name;
public int rollnumber;
public int phone;
}
static void Main(string[] args)
{
jeetu j;
jeetu i;
j.name = Console.ReadLine();
Console.WriteLine("the name of user is :" + j.name);
try
{
j.phone = int.Parse(Console.ReadLine());
Console.WriteLine("phone number of user is:" + j.phone);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
try
{
j.rollnumber = int.Parse(Console.ReadLine());
Console.WriteLine("rollnumber of user is:" + j.rollnumber);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
i = j;
Console.WriteLine("another structure is :" + i.name);
Console.WriteLine("pho :" + i.phone);
Console.WriteLine("roll:" + i.rollnumber);
}
}
}
Comment