Spyder.Snyper

Alright, so I'm making a class. Easy enough to do. But I want to add some nice functionality to it.

I want to be able to modify class members easily. For example...

I want to be able to reference Class.Note

I want to be able to get or set Class.Note

And since Class.Note would be a string, it (should) be pretty easy to do.

So... What do I need to do in my class to ensure that this is done properly


Re: Visual C# General Class.something

Mattias Sjogren

You need a property called Note of type string.

public string Note { get {... } set { ... } }

The rest should be covered by any introductory book to C#.






Re: Visual C# General Class.something

Spyder.Snyper

that's it!

damn... I thought it was something slightly (read: much) more complex than THAT...

Well... thanks for making me feel like an idiot...lol...




Re: Visual C# General Class.something

Spyder.Snyper

You know... I think I need to clarify my question though...

if I create a property like you describe above, would I still be able to do the following:

Class.Note = "Test Note."

and

string test = Class.Note




Re: Visual C# General Class.something

Jeremy Filburn

Yes you can as long as you have defined it as a static property or else you will have to create an instance first.

Code Snippet

private static string note = string.Empty;

public static string Note

{

get { }

set { }

}






Re: Visual C# General Class.something

Spyder.Snyper

Well thank you all.

Now that I feel like a TOTAL tool...

but at least I can continue...