[HelpRequest] C#

12/13/2011 12:47 andrewxxx#1
need examples (codesources) and some tuts about
  • Properties to your C# Classes (set and get)
  • Inheritance in C# .NET
i fully understand them but need more examples to get better with it
plus what u think the best step now (to create proxy for p.s/co)
learn more about sockets ?
thanks everyone ..
12/13/2011 16:25 pro4never#2
Hmmm well you can find most of those by googling but I suppose I can provide a quick explanation regardless.

Using get/set code simply makes dealing with variables easier. There will be LOTS of times when you want to perform actions every time something changes (think, saving data as it changes??) but it also makes it easier to avoid accidentally modifying data that shouldn't be.

For example... A mesh in a conquer server. You don't want to accidentally be screwing with a character's mesh or no one will be able to see them. Simply do something like...

public uint Mesh{get{return (uint)(Transformation * 10000000 + Face * 10000 + Body)}}

No one can ever assign to mesh cause there isn't 'really' a mesh variable, it's simply pulling from other variables and calculating them into something you can use!


Inheritance is very useful but can be a bit hard to understand when you're starting out. The easiest way to think about it (imo) is to play stupid word games.

All Trucks are Vehicles but not all Vehicles are Trucks. Whenever you can say something like that about one of your classes (All Players are Entities but not all Entities are Players) and you can EVER see using one of the other possibilities (monsters anyone?) then you should be using inheritance/interfaces.

The main difference between inheritance/interfaces.

1: You can only inherit directly from one other class/struct. This means you could do something like...

public class Player:Entity
You could NOT do Public class Player: BaseEntity, SocketClass, EtcClass

2: Interfaces can be thought of as structures for your class. Everything in an interface must still be implemented in each class. This is useful in some situations and annoying in others (I wouldn't want to write an IEntity interface and then have to duplicate ALL my entity variable implementations inside monster AND player class)

Was gonna write examples but I got tired...

as for proxy stuff...

[Only registered and activated users can see links. Click Here To Register...]

There's also some great "make a custom source" tutorials in the pserver release section which goes indepth with sockets and such.
12/13/2011 23:35 BaussHacker#3
A property is usually used when you need to do something when a variable is changed, so you don't have to send a method everytime you update a variable, then you can call it within the variable. get, set in that case.
Other times you can use get where you just get a variable, usually a private variable, because you should not be able to change it without the class, but only read the changes of it.

[Only registered and activated users can see links. Click Here To Register...]
12/14/2011 01:58 andrewxxx#4
30 min ago i wrote too much stuff and its my progress in learning ! i consider it so valuable i didnt delete it just spoiled it so for who care to see how i teached it myself and understanded it fully u can read at the spoiler :P XD thanks guyssss alot :D

now reading some about interface properties =)) expect another spoiler soon =)) kidding :P




here is one more question :D about how when it change
the value it get the new value if it was given by set/get xD



now when we was trying to give fmsg the value of
birthdaymessege.myprop it didnt took the value it have
, it gone to the class first to check if the value update
(in another words to take the value again)
and then give it to the fmsg , so this what u mean pro :D ?