|
Hi any one.
i want to create some class library and allow user to add it some data in a Collection.(example of it is Items property in Combobox or listbox).
i define a Dictionary collection and when using , it appear in control library but when i click it to add some data it show a disabled window.
its my public property:
public Dictionary<int32,> States
{
get
{
return MySexCell.States;
}
set
{
MySexCell.States = value;
}
}
sepel
modified on Tuesday, October 7, 2008 2:01 PM
|
|
|
|
|
sepel wrote: public Dictionary<int32,> States
Does that even compile? You need two datatypes in a Dictionary definition, one type for the key and one for the value.
Perhaps you should use a List instead of a Dictionary ?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I'm to being DIZZY .
i write dictionary (int32,string)but it dosen't appear.(using "(" instade of "<")
take it easy . i try to use List.
But think about this forum syntax way does not appear my code.
I test another type for my second Dictionary parameter but after post it no one appear.
sepel
modified on Tuesday, October 7, 2008 1:52 PM
|
|
|
|
|
MySexCell? *sniggers* Just what kind of application is this?
You probably don't want to expose a "set" accessor. That is if you want people to change the entire dictionary. People can "get" the dictionary and then call .Add on it.
You need to google the correct attributes to put on your property to enable designer support.
|
|
|
|
|
Hahahah.(MySexCell)
it is a cell that for male or female that saved in bit format in db, show corespond string such as "man or woman or Mr or
Mrs,...".
i think i should use Attribute . tnx
sepel
|
|
|
|
|
Suppose I have this class:
public abstract class EmployeeBase
{
public string _sEmpName = "Some One";
public int _iPayRate = 0;
public abstract string sEmpName
{
get;set;
}
public abstract int iPayRate
{
get;set;
}
public abstract void CalcPay();
}
I then subclass it as:
public class FTEmployee : EmployeeBase
{
private new string _sEmpName;
private new int _iPayRate = 0;
public override string sEmpName
{
get {return _sEmpName;}
set {_sEmpName = value;}
}
public override int iPayRate
{
get {return _iPayRate;}
set {_iPayRate = value;}
}
public override void CalcPay()
{
}
}
I'm trying to define the _sEmpName member in the base class and make it private in the subclass, but when I test it, the _sEmpName member contains Null.
Can someone help a newbie?
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: when I test it, the _sEmpName member contains Null.
Not in the base class it isn't.
You have two _sEmpName members - one in the base class and one
in the derived class.
Sounds like you just need the one in the base class.
Only methods/accessors can be abstract.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
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
|
|
|
|