|
What I'm trying to do is define the member in the base, then make it private in the subclass so that the property implementations can access it.
When I made the members private in the base I get the error
"Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: When I made the members private in the base I get the error
"Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
Correct. As John mentions below, you can't access a private member
outside the class, including derived classes.
Try protected instead.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Make the variables private in the base class and don't define them in the derived class since you inherit them
KMAROIS wrote: public abstract class EmployeeBase
{
private string _sEmpName = "Some One";
private int _iPayRate = 0;
KMAROIS wrote: public class FTEmployee : EmployeeBase
{
private new string _sEmpName;
private new int _iPayRate = 0;
led mike
|
|
|
|
|
A private variable isn't visible to derived classes - he has to make them protected if he wants them visible unless he has public (or protected) properties.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Bingo! That's what I was looking for.
Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
John Simmons / outlaw programmer wrote: he has to make them protected
correct, my mistake. Good thing compilers tell me about my errors like that eh?
led mike
|
|
|
|
|
I tried that, but then the property implementations in the FTEmployee class I get the error "Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
That' why I thought I needed to make the public in the base and private in the subclass.
Everything makes sense in someone's mind
|
|
|
|
|
Looks like you're also using the new keyword in the derived class as well. Get rid of new (unless you WANT to disregard the members in the base class) and mark the base classes members as protected as John pointed out. Another maybe unwanted tip here would to use constructors to force a fully instantiated object when it's created. Mark the setters as private and assign them in the constructor. Otherwise you'll have 3 lines and a possibly unusable object as opposed to one line and reliable data.
public abstract class EmployeeBase {
private string _sEmpName = "Some One";
private int _iPayRate;
protected EmployeeBase(String name, int payrate) {
EmployeeName = name;
PayRate = payrate;
}
public string EmployeeName {
get { return _sEmpName; }
private set { _sEmpName = value; }
}
public int PayRate {
get { return _iPayRate; }
private set { _iPayRate = value; }
}
public abstract void CalcPay();
}
public class FTEmployee : EmployeeBase {
public FTEmployee(String name, int payrate) :
base(name, payrate) {
}
public override void CalcPay() {
}
}
public void SomeNonsense() {
FTEmployee employee = new FTEmployee("James Harwood", 65000);
}
hope that helps...
Oh, and if you're using .NYET 2.0 have a look at Auto-Properties so you don't have to always implement the backing field in a property.
Scott P
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
You don't need to have
private new string _sEmpName;
private new int _iPayRate = 0;
in the derived class. The public properties should work for you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Can any one help,
Is the Conversion of VB.net 2.0 code to ASP is possible or not?
Thanks,
|
|
|
|
|
Depends. Assuming you mean asp.NET, then any non-gui related code (such as business logic and database logic) should be reusable, but the gui bits will have to be re-worked.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi all..
can anyone help me..i am retrieving data from sql in a dataset, i wanna create a dynamic table to place the values in.
the table must look as follows:
Account Name Date
AccountName UserName UserDate
the first row is normal text inserted by me, the second row is retrieved from the dataset...can anyone plz assist me on this.
living life on the flip side
|
|
|
|
|
Agweet wrote: i wanna create a dynamic table
Why? That would be something that a stored procedure might do but not an application.
led mike
|
|
|
|
|
i am going to use the table and insert it into an email so that the user can view newly added data
living life on the flip side
|
|
|
|
|
Agweet wrote: i am going to use the table and insert it into an email so that the user can view newly added data
That's not a complete enough description of your requirements for me to understand. For example: "newly added data" is an ambiguous statement.
Good luck
led mike
|
|
|
|
|
Agweet wrote: Account Name Date
AccountName UserName UserDate
Are you sure your table is going to have this structure?
You can create a datatable object and manually insert all this into it.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
Particularly in dataset we can't.But of ur requirement is dynamically display the data right,so you go< for
Gridview control and set AutogenretedColumns=false.Then u go designing or write TemplateField in the below of <column> tag ..there is you write whatever columns field you want ok.
like ex: <templatefield headertext=colName field="<%Eval(originalcolumnfield)%>">
If u know well otherwise i can't
modified on Tuesday, October 7, 2008 3:06 PM
|
|
|
|
|
Hi,
Can i use comports in a windows service ?
if yes, how does i know the portnumber when no user has logged onto windows ?
for me as user the comport is 6 and 7 instead of 1 and 2.
can i build a service than, using comport 6 and start the service with local system account ?
thx for you're help.
Kurt
|
|
|
|
|
topcatalpha wrote: Can i use comports in a windows service ?
Yes
topcatalpha wrote: i know the portnumber when no user has logged onto windows
We made ours configurable so we could change comports easily. Whether some one has logged into the system or not makes no difference as the comport is still there.
Just open com 6 or 7 as usual
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
ok thx. I will try it.
thx
|
|
|
|
|
Good afternoon!
Any one could tell me if this is possible? Could I access a remote machine port by sms, and control its parameters?
Thanks in advance.
My best regards.
|
|
|
|
|
Which incarnation of the acronym "SMS" are you referring to??
Can you control the parameters of a port opened on a remote machine?? Not likely, but you haven't said what you're really trying to accomplish with the method either.
|
|
|
|
|
Sorry SMS - Cell Phone Message
I'm trying to connect with a remote system via gsm and make data acquisition. But i need to give some commands to the equipment via it's RS485 port. There's any other way to do this?
Best regards.
|
|
|
|
|
write a bit of software that takes an SMS as input and outputs RS485. Then connect the output of the computer to the input the hardware.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Hello
To: all expert person
I need know method create code C# to DLL ,Please kind help me find this method
Thank you very much
|
|
|
|