Am working in console applications with visual studio in c# language.am new to this and am having silly doubts..
Am using a method with parameters as
public void display(int rank)
{
Console.WriteLine("rank is:" +rank);
}
Now I want to assign this value to a variable and have to display.i write the method as
public void get(int rank)
{
string a;
a = rank;
Console.WriteLine("rank is:" +a );
}
but am getting the error while accessing this through main function creating objects.Where am going wrong?
You don’t mention what error you get, but from what i can see, you’re trying to assign a string to an int (
a = rank). Convert it to a string before assigning: