Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

asp.net, c#, object c# 3.0

I have the following codes working fine but I want to create new cs called customerMethods
and put the codes like the following there.

        public string GetContactInfo() { return Name; }
        public string GetTransactionHistory() { return "History"; }

Is it possible? When I try it, Name does not recognize, so I put Company.Business.Model.Name but still does not work....any experts can help?



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Company.Business.Model
{
    public class Customer
    {
        // Auto-Impl Properties for trivial get and set
        public double TotalPurchases { get; set; }
        public string Name { get; set; }
        public int CustomerID { get; set; }

        // Constructor
        public Customer(double purchases, string name, int ID)
        {
            TotalPurchases = purchases;
            Name = name;
            CustomerID = ID;
        }
        // Methods
        public string GetContactInfo() { return Name; }
        public string GetTransactionHistory() { return "History"; }

        //http://msdn.microsoft.com/en-us/library/bb384054.aspx
        // .. Additional methods, events, etc.
    }
     

}
0
solution1368
Asked:
solution1368
  • 4
  • 4
1 Solution
 
informaniacCommented:
Not getting

return this.Name;
0
 
informaniacCommented:
Oh. You mean you want to create a new CS file?

You can create a new CS file.

But you have to use partial class feature then.

http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx
0
 
solution1368Author Commented:
if you mean  public string GetContactInfo() { return this.Name; }, it does not work.
remember, I want to put  public string GetContactInfo() { return Name; } in a separate .cs page.

Thanks
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.

 
solution1368Author Commented:
any way not to use partial? First of all, I used to see people doing this without partial,
second, the GetContInfo() may be located into another class not within the current solution file as well.
0
 
informaniacCommented:
Static you can use. Bt not sure how it will behave.

public static class Customer
{
         public static string Name{get; set;}
}
0
 
solution1368Author Commented:
the static class can not create new instance and I don't think this is a solution...Agree?
0
 
informaniacCommented:
Yes. that's what. It doesn't fit properly.. I'm not sure about where and how you've seen other solutions.
0
 
solution1368Author Commented:
ok...then may be i can wait and see other experts have ideas. Thanks
0
 
käµfm³d 👽Commented:
What is the purpose of this new .cs file you would like to create? What benefit are you looking to gain?
0

Featured Post

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.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now