Register for your free account! | Forgot your password?

You last visited: Today at 14:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HelpRequest] C#

Discussion on [HelpRequest] C# within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2009
Posts: 239
Received Thanks: 78
[HelpRequest] C#

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 ..
andrewxxx is offline  
Old 12/13/2011, 16:25   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
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 ******** 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...



There's also some great "make a custom source" tutorials in the pserver release section which goes indepth with sockets and such.
pro4never is offline  
Thanks
1 User
Old 12/13/2011, 23:35   #3
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
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.

BaussHacker is offline  
Thanks
1 User
Old 12/14/2011, 01:58   #4
 
elite*gold: 0
Join Date: May 2009
Posts: 239
Received Thanks: 78
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

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




here is one more question 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 ?
andrewxxx is offline  
Reply




All times are GMT +1. The time now is 14:23.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.