Hi
why is this not possible (name="Bob") and why is this allowed: static string name="Bob"?
Thanks
using System;
public class oef2
{
static string naam;
name="Bob";
public static void Welkom()
{
Console.WriteLine("Welkom " + name + " !");
}
public static void Main(string[] args)
{
Welkom();
}
}
Rajanikant HawaldarPosted Jun 26, 2021, 9:58 AM
in non static class, static member can be initialized at it declaration or in static contrunctor. in non static class you can not access static member directly you have access through class name.
Valerie MeunierPosted Jun 26, 2021, 10:18 AM
Sachin SinghPosted Jun 26, 2021, 10:07 AM