C#, how can i make an object/var?

Hi,

well, i dont know how to explain it, but… i want to declare a variable with multiple values.

for example, i have a button called refresh:

string refreshName = “refresh”;
float refreshWidth = 50f;
float resfreshHeight = 30f;
etc…

i want to make something like this:
public RefreshButton = {string name=“refresh”, float width=50f, float height=30f, float x=2f, float y=3f};

and then use:RefreshButton.name
Gui.button(new rect(RefreshButton.x,RefreshButton.y,RefreshButton.width,RefreshButton.height)myRefreshButton.name);

Its that possible??

yes

you can define a struct/class with those members:

public struct RefreshButton
{
    public string Name;
    public float Width;
    public float Height;
}

//elsewhere
RefreshButton btn = new RefreshButton();
btn.Name = "refresh";
btn.Width = 50.0f;
btn.Height = 30.0f;

you can even have a constructor that accepts those values passed in as params.

If you want a hash table though. Where you don’t have to create a class/struct definition. You’ll need to use a Dictionary or a HashTable for it.

Thank you, that’s awesome!!!

public struct myBtn{
	public string Name;
	public float Width;
	public float Height;
	public myBtn(string Name, float Width, float Height){
	   	this.Name = Name;
		this.Width = Width;
		this.Height = Height;
	}
}

myBtn RefreshButton = new myBtn("Refresh",50f,30f);