MrDysprosium MrDysprosium - 2 months ago 4x
C# Question

How do I use a variable outside of a partial class?

I'm new to C#, and I'm new to the idea of "partial" classes.

I wish to access the "grid" variable outside of this "MainWindow" class. How would I go about doing that?

enter image description here


Partial means that your class is split among different files, it has nothing to do with the exposure of variables to other classes.

Your grid is a local variable in your current method, so it's not accessible by others. If you want to make it accessible, define it as a property instead.

public DataGrid Grid { get; set; }