How Can I assign value to Struct variables?

  • Thread starter Thread starter Ñ©ÔÆÓ¥
  • Start date Start date
Ñ

Ñ©ÔÆÓ¥

Hi,all

I have a trouble about struct variable,the detail is :

I define a new struct which name ServiceProperty,then I declare a variable
like this:

ServiceProperty instService = null;

but compile throw error: error CS0037: ÎÞ·¨½« NULL ת»»³É
¡°ServiceProperty¡±£¬ÒòΪËüÊÇÒ»ÖÖÊýÖµÀàÐÍ


How shoud I do? please give me some tips,thank you very much.
 
structs are value types and cannot be null. a struct has a default state
such as int default 0.

Regards,
Jeff
 
Perhaps if you explained further what a ServiceProperty is and what you
use it for. (I ask because I suspect that it should be a class, not a
struct, but without further information I can't be sure.)
 
Back
Top