?
Solved

asp.net, c#, object c# 3.0

Posted on 2013-01-19
9
Medium Priority
?
157 Views
Last Modified: 2013-02-06
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
Comment
Question by:solution1368
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38796757
Not getting

return this.Name;
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38796777
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
 

Author Comment

by:solution1368
ID: 38796784
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
DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

 

Author Comment

by:solution1368
ID: 38796813
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
 
LVL 20

Expert Comment

by:informaniac
ID: 38796873
Static you can use. Bt not sure how it will behave.

public static class Customer
{
         public static string Name{get; set;}
}
0
 

Author Comment

by:solution1368
ID: 38796878
the static class can not create new instance and I don't think this is a solution...Agree?
0
 
LVL 20

Accepted Solution

by:
informaniac earned 2000 total points
ID: 38796894
Yes. that's what. It doesn't fit properly.. I'm not sure about where and how you've seen other solutions.
0
 

Author Comment

by:solution1368
ID: 38797254
ok...then may be i can wait and see other experts have ideas. Thanks
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38797791
What is the purpose of this new .cs file you would like to create? What benefit are you looking to gain?
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question