We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

need to create a custom class called Personal.cs. I have done some things. Need someone to check it out.

mathieu_cupryk
on
Medium Priority
218 Views
Last Modified: 2012-05-06
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;


/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }

    public Personal

        (
         string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         int age,
         string gender,
         string seeking,
         string confirmationguid,
         string userid,
         string sessionid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
        this.UserIP = userip;
        this.SessionID = sessionid;
    }    

    private string username = string.Empty;
    public string UserName
    {
         get { return username;}
         set { username = value;}
    }

    private string password = string.Empty;
    public string Password
    {
        get { return password;}
        set { password = value;}
    }

    private string email = string.Empty;
    public string Email
    {
        get { return email;}
        set { email = value;}
    }

    private string firstname = string.Empty;
    public string FirstName
    {
        get { return FirstName;}
        set { FirstName = value;}
    }

    private string lastname = string.Empty;
    public string LastName
    {
        get { return LastName;}
        set { LastName = value;}
    }

    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return DOB;}
        set { DOB = value;}
    }

    private int age = 0;
    public int Age
    {
        get { return Age;}
        set { Age = value;}
    }  

    private string gender = string.Empty;
    public string Gender
    {
        get { return Gender;}
        set { Gender = value;}  
    }

    private string seeking = string.Empty;
    public string Seeking
    {
        get { return Seeking;}
        set { Seeking = value;}
    }

    private string confirmationguid = string.Empty;
    public string ConfirmationGUID
    {
        get { return ConfirmationGUID;}
        set { ConfirmationGUID = value;}
 
    }
 
    private string userip = string.Empty;
    public string UserIP
    {
        get { return UserIP;}
        set { UserIP = value;}
    }

    private string sessionid = string.Empty;
    public string SessionID
    {
        get { return SessionID; }
        set { SessionID = value; }

    }
   
}
Comment
Watch Question

It should be like this
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;
 
 
/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }
 
    public Personal
 
        (
         string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         int age,
         string gender,
         string seeking,
         string confirmationguid,
         string userip,
         string sessionid)
    {
        this.username = username;
        this.password = password;
        this.email = email;
        this.firstname = firstname;
        this.lastname = lastname;
        this.dob = dob;
        this.age = age;
        this.gender = gender;
        this.seeking = seeking;
        this.confirmationguid = confirmationguid;
        this.userip = userip;
        this.sessionid = sessionid;
    }
 
    private string username = string.Empty;
    public string UserName
    {
        get { return username; }
        set { username = value; }
    }
 
    private string password = string.Empty;
    public string Password
    {
        get { return password; }
        set { password = value; }
    }
 
    private string email = string.Empty;
    public string Email
    {
        get { return email; }
        set { email = value; }
    }
 
    private string firstname = string.Empty;
    public string FirstName
    {
        get { return firstname; }
        set { firstname = value; }
    }
 
    private string lastname = string.Empty;
    public string LastName
    {
        get { return lastname; }
        set { lastname = value; }
    }
 
    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return dob; }
        set { dob = value; }
    }
 
    private int age = 0;
    public int Age
    {
        get { return age; }
        set { age = value; }
    }
 
    private string gender = string.Empty;
    public string Gender
    {
        get { return gender; }
        set { gender = value; }
    }
 
    private string seeking = string.Empty;
    public string Seeking
    {
        get { return seeking; }
        set { seeking = value; }
    }
 
    private string confirmationguid = string.Empty;
    public string ConfirmationGUID
    {
        get { return confirmationguid; }
        set { confirmationguid = value; }
 
    }
 
    private string userip = string.Empty;
    public string UserIP
    {
        get { return userip; }
        set { userip = value; }
    }
 
    private string sessionid = string.Empty;
    public string SessionID
    {
        get { return sessionid; }
        set { sessionid = value; }
 
    }
 
}

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
If using .NET 3.5 you can do that way.
This will simplifier your code.
//Declare you class object with properties
-----------------------------------------------
public class MyClass
{
    public string LastName { get; set; }
    public string FirstName { get; set; }
 
    public MyClass(){}
}
 
//Create a new instance of the MyClass object
-----------------------------------------------
MyClass oMc = new MyClass(){
    LastName = "MyLastName",
    FirstName = "MyFirstName"
};

Open in new window

Top Expert 2013
Commented:
looks good ..had some problem ... part of your code is shown below with changes in bold:

private string firstname = string.Empty;
    public string FirstName
    {
        get { return firstname; }
        set { firstname = value; }
    }

    private string lastname = string.Empty;
    public string LastName
    {
        get { return lastname; }
        set { lastname = value; }
    }

    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return dob; }
        set { dob = value; }
    }

    private int age = 0;
    public int Age
    {
        get { return age; }
        set { age = value; }
    }

    private string gender = string.Empty;
    public string Gender
    {
        get { return gender; }
        set { gender = value; }
    }

    private string seeking = string.Empty;
    public string Seeking
    {
        get { return seeking; }
        set { seeking = value; }
    }

    private string confirmationguid = string.Empty;
    public string ConfirmationGUID
    {
        get { return confirmationguid; }
        set { confirmationguid = value; }

    }

    private string userip = string.Empty;
    public string UserIP
    {
        get { return userip; }
        set { userip = value; }
    }

    private string sessionid = string.Empty;
    public string SessionID
    {
        get { return sessionid; }
        set { sessionid = value; }

    }

//Also just wondering if you want your ConfirmationGuid of type string or Guid...depending if you are storing in DB.


Author

Commented:
also what do I need to assign the dob = ????

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;


/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }

    public Personal

        (
         string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         int age,
         string gender,
         string seeking,
         string confirmationguid,
         string userid,
         string sessionid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
        this.UserIP = userip;
        this.SessionID = sessionid;
    }    

    private string username = string.Empty;
    public string UserName
    {
         get { return username;}
         set { username = value;}
    }

    private string password = string.Empty;
    public string Password
    {
        get { return password;}
        set { password = value;}
    }

    private string email = string.Empty;
    public string Email
    {
        get { return email;}
        set { email = value;}
    }

    private string firstname = string.Empty;
    public string FirstName
    {
        get { return firstname; }
        set { firstname = value; }
    }

    private string lastname = string.Empty;
    public string LastName
    {
        get { return lastname; }
        set { lastname = value; }
    }

    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return dob; }
        set { dob = value; }
    }

    private int age = 0;
    public int Age
    {
        get { return age; }
        set { age = value; }
    }  

    private string gender = string.Empty;
    public string Gender
    {
        get { return gender; }
        set { gender = value; }  
    }

    private string seeking = string.Empty;
    public string Seeking
    {
        get { return seeking; }
        set { seeking = value; }
    }

    private string confirmationguid = string.Empty;
    public string ConfirmationGUID
    {
        get { return confirmationguid; }
        set { confirmationguid = value; }
 
    }
 
    private string userip = string.Empty;
    public string UserIP
    {
        get { return userip; }
        set { userip = value; }
    }

    private string sessionid = string.Empty;
    public string SessionID
    {
        get { return sessionid; }
        set { sessionid = value; }

    }
   
}

and i think in 3.5 we can do a get set in less code.
Top Expert 2009

Commented:
You have to pass a DateTime parameter.
Commented:
To avoid multiples syntax error possibility (like i can see) use my solution if using .net 3.5.

You don't need to declare a private variable until you need to manipulate this variable in the "set" or "get" action.
You can also assign dob as DateTime.MinValue so that you can identify that it is a default value
private DateTime dob = DateTime.MinValue;

Open in new window

Author

Commented:
jacob can u fix this?

Author

Commented:
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;


/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }

    public Personal

        (
         string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         int age,
         string gender,
         string seeking,
         string confirmationguid,
         string userid,
         string sessionid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
        this.UserIP = userip;
        this.SessionID = sessionid;
    }    

    private string username = string.Empty;
    public string UserName { get; set; }

    private string password = string.Empty;
    public string Password { get; set; }

    private string email = string.Empty;
    public string Email { get; set; }

    private string firstname = string.Empty;
    public string FirstName { get; set; }

    private string lastname = string.Empty;
    public string LastName { get; set; }

    private DateTime dob = DateTime.MinValue;
    public DateTime DOB { get; set; }
 
    private int age = 0;
    public int Age { get; set; }
   
    private string gender = string.Empty;
    public string Gender { get; set; }
   
    private string seeking = string.Empty;
    public string Seeking { get; set; }

    private string confirmationguid = string.Empty;
    public string ConfirmationGUID { get; set; }
   
    private string userip = string.Empty;
    public string UserIP { get; set; }
   
    private string sessionid = string.Empty;
    public string SessionID { get; set; }
   
}
Top Expert 2009

Commented:

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;
 
 
/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }
 
    public Personal
 
        (
         string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         int age,
         string gender,
         string seeking,
         string confirmationguid,
         string userid,
         string sessionid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
        this.UserIP = userip;
        this.SessionID = sessionid;
    }    
 
    public string UserName { get; set; }
 
    public string Password { get; set; }
 
    public string Email { get; set; }
 
    public string FirstName { get; set; }
 
    public string LastName { get; set; }
 
    public DateTime DOB { get; set; }
 
    public int Age { get; set; }
   
    public string Gender { get; set; }
   
    public string Seeking { get; set; }
 
    public string ConfirmationGUID { get; set; }
   
    public string UserIP { get; set; }
   
    public string SessionID { get; set; }
   
}

Open in new window

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.