Persons Info class : Class Definition « Class Interface « C# / C Sharp






Persons Info class

        
using System;
using System.Diagnostics;
using System.IO;
using System.ServiceModel;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.Serialization;
using System.Text;

namespace Common
{


    [DataContract]
    public class PersonsInfo
    {
        private int m_Id;
        private string m_NickName;
        private string m_FirstName;
        private string m_LastName;
        private DateTime m_Birthday;
        private string m_Gender;
        private int m_Status;
        private string m_Email;
        private SortedList<int, string> m_Contacts;
        private bool m_NotPublic;
        public PersonsInfo(int id, string firstname, string lastname, DateTime birthday, string gender, string nickname, string email, int status, bool notpulic)
        {
            m_Id = id;
            m_LastName = lastname;
            m_FirstName = firstname;
            m_Birthday = birthday;
            m_Gender = gender;
            m_NickName = nickname;
            m_Email = email;
            m_Status = status;
            m_Contacts = new SortedList<int, string>();
            m_NotPublic = notpulic;
        }

        public PersonsInfo()
        { }

        public bool AddContact(int id, string AltName)
        {
            if (!m_Contacts.ContainsKey(id) && !m_NotPublic)
            {
                m_Contacts.Add(id, AltName);
                return true;
            }
            else return false;
        }

        [DataMember]
        public int Id
        {
            get
            {
                return m_Id;
            }
            set { m_Id = value; }
        }

        [DataMember]
        public string NickName
        {
            get
            {
                return m_NickName;
            }
            set { m_NickName = value; }
        }

        [DataMember]
        public string FirstName
        {
            get
            {
                return m_FirstName;
            }
            set { m_FirstName = value; }
        }
        [DataMember]
        public string LastName
        {
            get
            {
                return m_LastName;
            }
            set { m_LastName = value; }
        }
        [DataMember]
        public DateTime Birthday
        {
            get
            {
                return m_Birthday;
            }
            set { m_Birthday = value; }
        }

        [DataMember]
        public string Gender
        {
            get
            {
                return m_Gender;
            }
            set { m_Gender = value; }
        }

        [DataMember]
        public int Status
        {
            get
            {
                return m_Status;
            }
            set { m_Status = value; }
        }

        [DataMember]
        public string Email
        {
            get
            {
                return m_Email;
            }
            set { m_Email = value; }
        }

        [DataMember]
        public SortedList<int, string> Contacts
        {
            get
            {
                if (!m_NotPublic)
                    return m_Contacts;
                else return null;
            }
            set { m_Contacts = value; }
        }


    }

}

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.simulate a bank account
2.Using Initializers
3.A simple inventory exampleA simple inventory example
4.Declaring and Defining Classes
5.Declaring Class Instances
6.Assign value to classAssign value to class
7.Declare class and use itDeclare class and use it
8.Illustrates how to declare classes, object references, and create objectsIllustrates how to declare classes, object references, and create objects
9.Illustrates how to assign default values to fields using initializersIllustrates how to assign default values to fields using initializers
10.illustrates how to use a 'has a' relationshipillustrates how to use a 'has a' relationship
11.Illustrates nested classesIllustrates nested classes
12.Multiple constructors in a class definitionMultiple constructors in a class definition
13.Demonstrate the use of a nested class to contain dataDemonstrate the use of a nested class to contain data
14.Show name hiding in a derived classShow name hiding in a derived class
15.Illustrates hidingIllustrates hiding
16.Variable in and out a classVariable in and out a class
17.Create classCreate class
18.A program that uses the Building classA program that uses the Building class
19.This program creates two Building objectsThis program creates two Building objects
20.Return an objectReturn an object
21.Uses a class from Example16_3a.cs
22.A Simple C# ClassA Simple C# Class
23.Message class
24.Point class