[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Initialize an object?

Posted on 2009-02-09
9
Medium Priority
?
197 Views
Last Modified: 2012-05-06
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;
    }
How should I setup the above object?

Open in new window

0
Comment
Question by:mathieu_cupryk
  • 4
  • 4
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 23591605
I'm not quite sure what you are getting at. What is wrong with your struct declaration as it is?
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23591803
Did you mean how to intialize stuct object?
SIMObject obj = new SIMObject();

Open in new window

0
 

Author Comment

by:mathieu_cupryk
ID: 23591826
Error      1      'SIMObject': member names cannot be the same as their enclosing type      W:\webs\CarrierStubs\App_Code\PCM\SIMObject.cs      16      19      W:\webs\CarrierStubs\
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Expert Comment

by:sunithnair
ID: 23591861
Are you having this struct inside the class with the same name as the struct? Either rename the struct or the class..
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23591870
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
0
 

Author Comment

by:mathieu_cupryk
ID: 23591895
Can you please show me how I should set this up?
0
 

Author Comment

by:mathieu_cupryk
ID: 23591926
Error      7      'PCM.SIMObject.SimID': cannot have instance field initializers in structs      W:\webs\CarrierStubs\App_Code\PCM\SIMObject.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;
    }
   
}
0
 
LVL 16

Accepted Solution

by:
sunithnair earned 2000 total points
ID: 23592140
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;
        public string SimNumber;
        public string Msisdn;
        public string Imsi;
        public string Status;
        public string Profile;
        public string ActivationDate;
    public SIMObject
    {
        SimID = 0;
        SimNumber= string.Empty;
        Msisdn= string.Empty;
        Imsi= string.Empty;
        Status= string.Empty;
        Profile= string.Empty;
        ActivationDate= string.Empty;
    }
    }
}
0
 

Author Comment

by:mathieu_cupryk
ID: 23592457
where is your bracket?
i get compilation error.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question