Attribute programming in C# -


I am new to attribute programming, not sure whether I am asking the right questions or not.

I have an abstract base class (abstactbase) and two drywired classes are Derive1 and Derived2. Two methods of My AbstartBase class are Method1 and Method2.

Is it possible to use this feature programming, so that when I do this

  AbstractBase ab = new Derived1 ();   

I only have access to Method1 and when I use the Derived2 class, then only select Method2 Access is available.

Is it possible if yes, then can you give me an example to start?

I think that you are connecting two to different types of codes or polymorphism and qualities of your problem What you can do in the situation, you can make an envelope with a method and implement it in your deriving classes differently, so that polymorphism can be used to implement your implementation. For example

  Public Interface IBase {void Foo (); } Public class Derived1: IBase {public void Foo ()} {/ print derived 1}} public class Derived2: IBase {public void Foo () {// print derived 2}} public class program {public static zero main ) []) (IBibase base = new derivative 1 (); base.fu (); // it printed 1 base = new derived2 (); Base.Foo (); // This passage returns 2}} < / Code>  

While attaching metadata to the members of your classes or classes in C # , While simultaneously applying a common practice, without implementing a certain interface for each unit sharing the behavior.

You getCustomAttribute () I need to call the attribute using the method I

  [MyAttribute] Public class MyClass {// class body}   

otherwise it will do nothing For more information about the specialty, please see this article. B It'll Helpls.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -