Question : C# - Can a partial class override a property's get method?

Using LINQ to SQL a class for a table is auto-generated - part of that class is below:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
public Alumni()
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_person_id", DbType="Char(8) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
		public string person_id
		{
			get
			{
				return this._person_id;
			}
			set
			{
				if ((this._person_id != value))
				{
					this.Onperson_idChanging(value);
					this.SendPropertyChanging();
					this._person_id = value;
					this.SendPropertyChanged("person_id");
					this.Onperson_idChanged();
				}
			}
		}
.
.
.


I want to override the person_id's get method in a partial class in order to trim any spaces:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
public partial class Alumni
    {

            public override string person_id
            {
                get { return this._person_id.Trim(); }
            }
.
.
.


The above approach does not work - the compile complains about the duplicated property person_id:
1:
2:
The type 'OnlineDirectory.Models.Alumni' already contains a definition for 'person_id'


Is there a way to do what I am trying to do from a partial class?

Answer : C# - Can a partial class override a property's get method?

No. Overriding is for changing the behavior of a property/method in a CHILD class. Partial classes are used to split code between multiple files for the same class. Why would you use a partial class anyways? Is there a reason not to change the definition of the property?

Here is a (personal) real-world example of using partial class:

I have an XML schema from which I use the xsd.exe tool that comes with VS to generate a class file for me; however, the generated class is missing some functionality I would like. If I change the generated file, every time the schema changes and I recreate the class, I lose whatever changes I made. Now, if I make a partial class and put my desired functionality in there, every time I generate a new object from an updated schema, *my* changes are not touched.
Random Solutions  
 
programming4us programming4us