c# Programming Glossary: obj1
Generated random numbers are always equal http://stackoverflow.com/questions/10598000/generated-random-numbers-are-always-equal Random return rand.Next 10 1 And 2 objects of it MyClass obj1 new MyClass MyClass obj2 new MyClass The problem is that obj1.MyMethod.. new MyClass MyClass obj2 new MyClass The problem is that obj1.MyMethod obj2.MyMethod always. Why does it happen What's the..
Possible pitfalls of using this (extension method based) shorthand http://stackoverflow.com/questions/123088/possible-pitfalls-of-using-this-extension-method-based-shorthand one would be comparing two nullable object properties if obj1 null obj2 null obj1 null obj2 null obj1.Property obj2.Property.. two nullable object properties if obj1 null obj2 null obj1 null obj2 null obj1.Property obj2.Property ... becomes if obj1.NullCompare.. properties if obj1 null obj2 null obj1 null obj2 null obj1.Property obj2.Property ... becomes if obj1.NullCompare obj2..
General type conversion without risking Exceptions http://stackoverflow.com/questions/2111280/general-type-conversion-without-risking-exceptions 2009 DateTime theDate new DateTime 2009 11 1 IComparable obj1 theString as IComparable IComparable obj2 theDate as IComparable.. obj2.GetType if converter.CanConvertFrom obj1.GetType Console.WriteLine obj2.CompareTo converter.ConvertFrom.. Console.WriteLine obj2.CompareTo converter.ConvertFrom obj1 Console.WriteLine Date comparison catch FormatException ..
How to avoid Dependency Injection constructor madness? http://stackoverflow.com/questions/2420193/how-to-avoid-dependency-injection-constructor-madness to look like this public MyClass Container con SomeClass1 obj1 SomeClass2 obj2.... with ever increasing parameter list. Since..
When is using the C# ref keyword ever a good idea? http://stackoverflow.com/questions/3539252/when-is-using-the-c-sharp-ref-keyword-ever-a-good-idea Swap method as a valid exception void Swap T ref T obj1 ref T obj2 T temp obj1 obj1 obj2 obj2 temp but at the same time.. a valid exception void Swap T ref T obj1 ref T obj2 T temp obj1 obj1 obj2 obj2 temp but at the same time a comment remarks Swap.. exception void Swap T ref T obj1 ref T obj2 T temp obj1 obj1 obj2 obj2 temp but at the same time a comment remarks Swap always..
Reference equality performance difference? ((object)obj1 == (object)obj2) vs. object.ReferenceEquals( obj1, obj2 ) http://stackoverflow.com/questions/735554/reference-equality-performance-difference-objectobj1-objectobj2-vs-ob equality performance difference object obj1 object obj2 vs. object.ReferenceEquals obj1 obj2 Is there extra.. object obj1 object obj2 vs. object.ReferenceEquals obj1 obj2 Is there extra overhead in using the object.ReferenceEquals.. the object.ReferenceEquals method verses using object obj1 object obj2 In the first case there would be a static method..
Looking for a fast and easy way to coalesce all properties on a POCO http://stackoverflow.com/questions/7422861/looking-for-a-fast-and-easy-way-to-coalesce-all-properties-on-a-poco properties here static class Program static void Main var obj1 new SamplePoco Field1 123 var obj2 new SamplePoco Field2 abc.. var obj2 new SamplePoco Field2 abc var merged Merger.Merge obj1 obj2 Console.WriteLine merged.Field1 Console.WriteLine merged.Field2..
How do I create dynamic properties in C#? http://stackoverflow.com/questions/947241/how-do-i-create-dynamic-properties-in-c Main string args create some objects and fill a list var obj1 new ObjectWithProperties obj1 test 100 var obj2 new ObjectWithProperties.. objects and fill a list var obj1 new ObjectWithProperties obj1 test 100 var obj2 new ObjectWithProperties obj2 test 200 var.. new List ObjectWithProperties new ObjectWithProperties obj1 obj2 obj3 filtering Console.WriteLine Filtering var filtered..
Type Checking: typeof, GetType, or is? http://stackoverflow.com/questions/983030/type-checking-typeof-gettype-or-is I've seen many people use the following code Type t typeof obj1 if t typeof int Some code here But I know you could also do.. int Some code here But I know you could also do this if obj1.GetType typeof int Some code here Or this if obj1 is int Some.. this if obj1.GetType typeof int Some code here Or this if obj1 is int Some code here Personally I feel the last one is the..
|