How to use class from other files in C# with visual studio?

前端 未结 6 938
孤独总比滥情好
孤独总比滥情好 2020-12-29 04:51

I am a newbie of C# and MS visual studio, and I want to use the C# class which defined in another file, but can\'t get it work.

Here is the program.cs

6条回答
  •  臣服心动
    2020-12-29 05:22

    namespace TestCSharp2
    {
        **public** class Class2
        {
            int i;
            public void setValue(int i)
            {
                this.i = i;
            }
            public int getValue()
            {
            return this.i;
            }
        }
    }
    

    Add the 'Public' declaration before 'class Class2'.

提交回复
热议问题