C# issue

01/26/2012 23:27 shadowman123#1
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
01/26/2012 23:31 I don't have a username#2
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.
01/27/2012 01:34 shadowman123#3
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 ??
01/27/2012 01:41 xskive#4
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 [Only registered and activated users can see links. Click Here To Register...]. 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.
01/27/2012 02:51 shadowman123#5
Wooooooooot That Website u gave me is Very Fu**** Cool ..Now My resources have been Increased
01/27/2012 07:19 I don't have a username#6
You could find it just by Googling.