Unnamed User

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

575 Good

About Unnamed User

  • Rank
    Newbie
  1. Speaking of C# that's because variable declaration and object instantiation are two different things Here we are just declaring a variable of type List<T> List<T> myList; It has no value, and is not initialized, it can't be used unless it's used in an out parameter What would happen if it automatically create a new instance of the object just by declaring it? If it was a value type, like an int or float there would be no problem at all, but it would never work for a reference type. First of all a reference type may not have a parameterless constructor, or it could be an abstract class or even an Interface, there would be no way to initialize then this way, or it could have no public constructors at all, what if it uses some kind of factory class to initialize the objects? And of course, what if you just want the variable to receive an instance from somewhere else? You do not always want a new object, sometimes you will receive it as a parameter or from calling some other function So you say it's a "List<T>", but how can the compiler know you really want a "new List<T>" and not an existing one, or some other object that inherits from List<T>? What if you really want a new List<T> but you want it to be created by a function that initializes it with some values?
  2. I just think it's way easier to write and read this enum MyFlags { Flag1 = 0x1, Flag2 = 0x2, Flag3 = 0x4, Flag4 = 0x8, Flag5 = 0x10, Flag6 = 0x20, Flag7 = 0x40, Flag8 = 0x80 }Than this enum MyFlags { Flag1 = 1, Flag2 = 2, Flag3 = 4, Flag4 = 8, Flag5 = 16, Flag6 = 32, Flag7 = 64, Flag8 = 128 }Both ways are easy to do, if I use decimal I just have to double the last value, but with hexadecimal I just have to remember the sequence 1, 2, 4 and 8 as it will just repeat itself over and over, just adding zeros to the end
  3. MEF and releasing imports.

    It's been a while since I worked with MEF but I think the problem is that you put the PartCreationPolicy in your custom attribute, it should be directly in the exported class, base class or interface.
  4. Have you ever considered using a custom attribute? If the value is static you could get the custom attribute on OtherClass<T> static constructor and hold it in a static field for later use, this way you only have to do it once for each type of OtherClass<T>
  5. [.net] Bitwise check - best way?

    You are only missing one nice feature of .Net, the FlagsAttribute [Flags] public enum DataType { None=0, Vertex=1, Index = 2, UV = 4, XYZ = 8, Norm = 16 } If you have something like DataType dt = DataType.Vertex | DataType.Index; If you are not using the FlagsAttribute, when you check the value while debugging or when you use the ToString you will see the value 3, as expected, but with FlagsAttribute you will see the value "Vertex | Index" while debugging and ToString will return "Vertex, Index" instead of 3, so you don't have to figure out which bits are set while debugging.
  6. [.net] mono

    I think it's good for Mono developers to run Test Cases, so they can run it on both Microsoft .Net Framework and Mono to see if it's behaving as expected. It might be good to test your app if you are targeting it to run on both frameworks too. I don't know any other benefit to it.
  7. Quote:Original post by thedustbustr The docs said that setting the select timeout to 0 meant that it would block. Setting the timeout to a small nonzero value seems wasteful. MSDN: Quote:timeout Maximum time for select to wait, provided in the form of a TIMEVAL structure. Set the timeout parameter to null for blocking operations. No, the docs said that setting the select timeout to NULL meant that it would block. This parameter is a pointer to a TIMEVAL struct, so just pass a TIMEVAL struct with both fields set to 0 MSDN Remarks: Quote: If TIMEVAL is initialized to {0, 0}, select will return immediately