Reference variable from a different method, class, file

后端 未结 4 1688
余生分开走
余生分开走 2021-01-29 10:54

I need to reference the value of a variable in a different method, class, and file than the one I am currently in. I am brand new to C# and still trying to get these concepts.

4条回答
  •  旧时难觅i
    2021-01-29 11:47

    I hope i will not confuse you even more.

    The "variable in the other class" should be a property of that class. You need to make sure it is public, and then, you need the AddRoute method get an instance of that class with that property set. You could then access the property value using something like otherClassInstance.xyz.

    If the above confuses you, I suggest starting at the beginning, learning about Object Oriented Programming before attempting any coding at all.

提交回复
热议问题