I cannot access a variable outside a class

后端 未结 3 1519
甜味超标
甜味超标 2021-01-28 15:52

I\'m making a blackjack project..

I\'ve firstly created the Hit class for the Hit Button.

So on the form, when I click it, it will retr

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 16:30

    Not sure if I understood completely.

    But I could see that stRefID is a variable local to GenerateID function.

    If you need to access it as Hit.stRefID then stRefID should be a static class member

    Try adding stRefID as static global Class variable.

    public class Hit
    {
        public static string stRefID = "";
    
        public static string GenerateID(int MinSize, int MaxSize)
        {
           //Your logic
        }
    

提交回复
热议问题