mathieu_cupryk
asked on
Initialize an object?
I need to create a class for a simobject
public struct SIMObject
{
public int SimID = string.Empty;
public string SimNumber = string.Empty;
public string Msisdn = string.Empty;
public string Imsi = string.Empty;
public string Status = string.Empty;
public string Profile = string.Empty;
public string ActivationDate = string.Empty;
}
public struct SIMObject
{
public int SimID = string.Empty;
public string SimNumber = string.Empty;
public string Msisdn = string.Empty;
public string Imsi = string.Empty;
public string Status = string.Empty;
public string Profile = string.Empty;
public string ActivationDate = string.Empty;
}
How should I setup the above object?
I'm not quite sure what you are getting at. What is wrong with your struct declaration as it is?
Did you mean how to intialize stuct object?
SIMObject obj = new SIMObject();
ASKER
Error 1 'SIMObject': member names cannot be the same as their enclosing type W:\webs\CarrierStubs\App_C ode\PCM\SI MObject.cs 16 19 W:\webs\CarrierStubs\
Are you having this struct inside the class with the same name as the struct? Either rename the struct or the class..
SIMObject.cs contains a class named SIMObject inside which you are defining the struct. You can also fully remove the class and have just the struct in the SIMObject.cs file
ASKER
Can you please show me how I should set this up?
ASKER
Error 7 'PCM.SIMObject.SimID': cannot have instance field initializers in structs W:\webs\CarrierStubs\App_C ode\PCM\SI MObject.cs 15 20 W:\webs\CarrierStubs\
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Web.UI.HtmlControls ;
namespace PCM
{
public struct SIMObject
{
public int SimID = string.Empty;
public string SimNumber = string.Empty;
public string Msisdn = string.Empty;
public string Imsi = string.Empty;
public string Status = string.Empty;
public string Profile = string.Empty;
public string ActivationDate = string.Empty;
}
}
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
namespace PCM
{
public struct SIMObject
{
public int SimID = string.Empty;
public string SimNumber = string.Empty;
public string Msisdn = string.Empty;
public string Imsi = string.Empty;
public string Status = string.Empty;
public string Profile = string.Empty;
public string ActivationDate = string.Empty;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
where is your bracket?
i get compilation error.
i get compilation error.