DataTypes

Hi

Kind of stupid doubt

When we use primitive data types like int, we never use new operator. but if we define our own datatype we need to use new operator.

Thanks in advance




Answer this question

DataTypes

  • Nicolas de Fontenay

    Sorry, My Question was how can we create a user Defined DataType and use it like how we use int.

    that is without using new operator



  • cgsdev

    In 1.1 you cannot null a value type... only in 2.0 so far.

    If building a class isn’t an option... the only other option I see is to use a symbolic null value... where you decided that say... -1 can never be used as a value and therefore when encountered should be treated as null.

    It’s not pretty, but those are really your only options... 2.0, class or symbolic null.



  • Ver Argulla Jr.

    Simply make your data type be a structure instead of a class.

    Classes are reference types and require explicit creation by using the new keyword, structs on the other hand are value types and are implicitly created when you define the variable, all without needing to use new.

    This is a fairly common thing in the framework where not only are numeric values struts, but so are things such as DateTime, String, Byte, Char and plenty more.



  • staceywilliam

    Where is the question


  • pmquan

    Hi

    I know we can use Struct. but problem is i want to create a datatype for storing Null Values (i am using .Net 1.1)

    When creating using structure, can i assign null



  • DataTypes