|
See the "Where Password Attributes Reside" section at this[^] page.
/ravi
|
|
|
|
|
I forgot to say , i develop by using c# .
NOT VBS.
|
|
|
|
|
How about this[^] article?
/ravi
|
|
|
|
|
So what? The concepts don't change just because the programming language did.
Or were you looking for copy'n'paste code?
|
|
|
|
|
The function and how to set the the property is difrent ..
|
|
|
|
|
No, it's not. The exact same concepts and procedures still apply. The only difference is you use the classes in the System.DirectoryServices namespace to do the searching and manipulation. If you understand the concepts behind that VBS code, it's very easy to figure out how to write the equivilent code by reading the documentation on System.DirectoryServices classes and looking at the examples there.
Research is the number one skill you MUST have in order to survive writing code for a living...
|
|
|
|
|
sure he wants copy'n'paste
|
|
|
|
|
In the code below why does the created test object use the variable x from the A class when using medoth PrintString? (As I thought the x in B class would overrided the x in A class even though the A PrintString was being used) How could I make the code use the x variable from the B class? do I have to put a version of the PrintString method in the B class?
Thanks in advance.
Rapier-503
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test_Inheritance
{
class Program
{
static void Main(string[] args)
{
B test = new B();
test.PrintString();
}
}
class A
{
string x = "Hello1";
public void PrintString()
{
Console.WriteLine(x);
}
}
class B:A
{
string x = "Hello2";
}
}
|
|
|
|
|
The short answer is "Yes".
The long one takes more explaining.
When the compiler looks at A.PrintString, it looks for a variable called x in the following places:
Local variables to PrintString
Method parameters to PrintString
Local instances of class A (this.x)
Static variables in class A (A.x)
Base classes for class A
When it find it, it compiles it to use that exact instance. It does not assume that it should look for an instance in a different, but related, class because it does not know until run time if this will be an instance of A or B (or of B passed as an A to a method).
If you want to access B.x in PrintString, then you must override it in class B to provide that functionality.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Thanks for the reply.
What I was trying to do was :-
A class has lots of members M1, M2 ..... M20 that use variable x.
B class need to do the same processing as M1... M20 but on a differnt value of x.
I didn't want to dulpicate all the M1...M20 code in B.
I must be not approaching this in the right way?
Any advice on how I should be doing this?
Thanks in Advance,
Rapier-503
|
|
|
|
|
It does sound like you are trying to approach this the wrong way. If you need a different value, but the same processing, then why do you not use A.x but change it's value in the B constructor instead of trying to mask the variable:
class A
{
protected string x = "Hello";
public void P()
{
Console.WriteLine(x);
}
}
class B : A
{
public B()
{
x = "Hello2";
}
}
Then:
A a = new A();
B b = new B();
a.P();
b.P();
will print:
Hello
Hello2 Which is what you want, isn't it?
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
This is exactly what I wanted Thank you I was missing the use of protected. I thought I must be missing something and over complicating things.
Thanks Again.
Rapier-503
|
|
|
|
|
If you build this in C# do you get a compiler warning? You should. The warning will tell you the error. BTW, don't use implicit access level modifiers even though MS in all of their boneheadedness thinks its ok.
Oh, and, if you look in class B and you remove the member variable type you get an illegal assignment instead of a declaration. Where could you put this assignment so that it was legal and always executed when be is instantiated?
|
|
|
|
|
Why should compiler issue a warning for this code? Private members aren't visible outside the class, so you can have members with the same name in every class in the inheritance chain. No warning will be issued.
|
|
|
|
|
lukasz_nowakowski wrote: No warning will be issued.
Try it!
It's time for a new signature.
|
|
|
|
|
My mistake...
|
|
|
|
|
Again, another reason implicit Access Modifiers are bad mojo.
|
|
|
|
|
Fields can't be overridden and I suspect you would still need to make the method virtual in order to override it.
|
|
|
|
|
Hello,
I want to simulate simple UPnP device in C#. Something like light-bull or door. It's school project about intelligent houses. I was looking for something on web, but now i am a bit lost . Can somebody give me some advice, how to start?
|
|
|
|
|
|
Can anybody tell the exact use of design/design patterns in C#.
Let me come with an example, i am designing a software for processing different type of input files. My design will be like this.
I will have a baseclass
class BaseFileClass
{
protected void ProcessFile();
}
Then the derived classes
class XMLClass : BaseFileClass
{
public override void ProcessFile()
{
}
}
class CSVCLass: BaseFileClass
{
public override void ProcessFile()
{
}
}
class ExcelClass: BaseFileClass
{
public override void ProcessFile()
{
}
}
On the main
Base b = null;
if( isXMl)
{
b = new XMLCLass();
}
else if( isExcel)
{
b = new ExcelCLass();
}
else if( isCSV)
{
b = new CSVCLass();
}
b.ProcessFile();
What are the uses of this kind of a design??
My small attempt...
|
|
|
|
|
I think that would be the, "I don't know the Abstract Factory Pattern Pattern".
|
|
|
|
|
hi Thanks for the update... do not misunderstand my intention..
i am not asking about design patterns, but what is the exact use of this kind of design?
My small attempt...
|
|
|
|
|
You might as well read up on that pattern while you wait for more responses.
|
|
|
|
|
In some manage system, this design pettern can be used.
For example, according to the type of the login account to new the object. The normal user, manager.
|
|
|
|