Register for your free account! | Forgot your password?

You last visited: Today at 00:11

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

Advertisement



C# issue

Discussion on C# issue within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
C# issue

Well i wanted to know the deff bet these 2 ways of using Dictionary

1st way is

Code:
public static Dictionary<uint, ClanArenaInt> ClanArena = new Dictionary<uint, ClanArenaInt>();
2nd way is

Code:
public static Dictionary<uint, ClanArenaInt> ClanArena;
And whats deff bet ThreadSafeDictionery , Dictionery , SafeDictionery ?? cuz in The Source im using i noticed that their structure and using Are the same
shadowman123 is offline  
Old 01/26/2012, 23:31   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
1st one is creating a new instance when declaring the variable, the 2nd one isn't lol. The 2nd one will give a null reference exception.

ThreadSafeDictionary is just a dictionary that can be accessed by multiple threads without conflicts. In 4.0 there is ConcurrentDictionary, which can handle that stuff, so ThreadSafeDictionary wrappers are pretty much useless.

SafeDictionary will I assume is the same, not sure what it's for. How is it used?

A dictionary is just a generic collection of a generic object with a generic key, the 2 other dictionaries are just wrappers around a regular dictionary.
I don't have a username is offline  
Thanks
1 User
Old 01/27/2012, 01:34   #3
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Correct me Guyz if iam Wrong ...i Seen how Struct Work and i've seen a comparison bet Class , Struct So the conclusion is that Class is faster then struct in usage so it not good to work with structs but what make me Confused how can i use struct if class is more efficient than it ??
shadowman123 is offline  
Old 01/27/2012, 01:41   #4
 
elite*gold: 0
Join Date: Sep 2011
Posts: 17
Received Thanks: 8
Quote:
Originally Posted by shadowman123 View Post
Correct me Guyz if iam Wrong ...i Seen how Struct Work and i've seen a comparison bet Class , Struct So the conclusion is that Class is faster then struct in usage so it not good to work with structs but what make me Confused how can i use struct if class is more efficient than it ??
The main thing to point out is that classes are "reference" types while structs are "value" types. If you don't know the difference between the two start reading . Another major aspect is the fact that structs do not support inheritance while classes do. (Again read if you don't understand this) Here is a simple C# program to show you difference between class "reference" and struct "value".

Code:
using System;

namespace DifferenceBetweenClassesAndStructures
{

    struct StrucutreExample
    {
        public int x;        
    }

    class ClassExample
    {
        public int x;        
    }

    class Program
    {
        static void Main(string[] args)
        {
            StrucutreExample st1 = new StrucutreExample(); // Not necessary, could have done StructureExample1 st1;
            StrucutreExample st2;

            ClassExample cl1 = new ClassExample();
            ClassExample cl2;                        

            cl1.x = 100;
            st1.x = 100;

            cl2 = cl1;
            st2 = st1;

            cl2.x = 50;
            st2.x = 50;

            Console.WriteLine("st1 - {0}, st2 - {1}", st1.x, st2.x);            
            Console.WriteLine("cl1 - {0}, cl2 - {1}", cl1.x, cl2.x);            
            Console.ReadLine();
        }
    }
}
EDIT: Didn't even answer your question...
Well, unlike classes, structs are created on stack. So, it is faster to instantiate and destroy a struct as opposed to a class. I'd recommend you Google this information for more details.
xskive is offline  
Thanks
1 User
Old 01/27/2012, 02:51   #5
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Wooooooooot That Website u gave me is Very Fu**** Cool ..Now My resources have been Increased
shadowman123 is offline  
Old 01/27/2012, 07:19   #6
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
You could find it just by Googling.
I don't have a username is offline  
Reply


Similar Threads Similar Threads
9D TH ISSUE
11/04/2011 - 9Dragons - 5 Replies
Pls help me out pplz, i just installed D9 TH and i cant seem to get it working, i still cant update the patch >_> any tip to get the game working? :(
[HELP]Plz Help Me Bug Issue
09/11/2011 - General Gaming Discussion - 2 Replies
Can anyone plz help me cause when i play ingame the game go all white like this
Having an issue
06/18/2010 - Shaiya Private Server - 0 Replies
On the server that I'm hosting, we've followed the tutorials to get the server to EP4 and gotten the server itself to work. All files attatched to SQL correctly (or so it said), using MSSQL 2005 Express. Here's the issue: All of the people who have our game.exe (which is staff only at the moment) who try to log on, make it to the character selection screen. All of their toons are there and able to be selected. However, when they click to start the game, it automatically DC's them. ...
Same issue..
02/11/2010 - Dekaron Private Server - 4 Replies
Please help.. Getting the same problem.. http://i167.photobucket.com/albums/u134/Scotticus 22/77.jpg
[Sun Sro] Res Issue
07/19/2009 - SRO Private Server - 12 Replies
Hi, Basically I want to have my sun sro client run at 1440x900 res. I have chosen this in the launcher options, however in-game this option doesn't appear. In fact no 16:10 options do which is really screwing my aspect ratio. Does anyone know of anyway to change the res on the sun sro client to 1440x900? Cheers, Profix



All times are GMT +1. The time now is 00:13.


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.