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 HawaldarRank #110 · 20.2K reputationPosted Jun 26, 2021, 5:58 AM EDT
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.
Sachin SinghRank #66 · 26.2K reputationPosted Jun 26, 2021, 6:07 AM EDT
Valerie MeunierRank #1,526 · 1K reputationPosted Jun 26, 2021, 6:18 AM EDT