• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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

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; }

    }
   
}
0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 3
  • 2
  • 2
  • +2
5 Solutions
 
sunithnairCommented:
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

0
 
jabcocoCommented:
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

0
 
guru_samiCommented:
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.


0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
mathieu_cuprykAuthor 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.
0
 
nmarunCommented:
You have to pass a DateTime parameter.
0
 
jabcocoCommented:
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.
0
 
sunithnairCommented:
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

0
 
mathieu_cuprykAuthor Commented:
jacob can u fix this?
0
 
mathieu_cuprykAuthor 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; }
   
}
0
 
nmarunCommented:

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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now