You can use the keyword access modifier internal to declare a type or type member as accessible to code in the same assembly only You can use the InternalsVisibleToAttribute class defined in System.Rutime. CompilerServices to declare a type as accessible to code in the same assembly or a specified assembly only You use the first as you use any other access modifier such as private To wit: internal class MyClass { ... } You use the second as follows: assembly:InternalsVisibleTo("MyFriendAssembly", PublicKey="...") internal class MyVisibleClass { ... } Both of these can rightly be considered the equivalent of friend in C Methods that are protected are already available to derived classes.
You can use the keyword access modifier internal to declare a type or type member as accessible to code in the same assembly only. You can use the InternalsVisibleToAttribute class defined in System.Rutime. CompilerServices to declare a type as accessible to code in the same assembly or a specified assembly only.
You use the first as you use any other access modifier such as private. To wit: internal class MyClass { ... } You use the second as follows: assembly:InternalsVisibleTo("MyFriendAssembly", PublicKey="...") internal class MyVisibleClass { ... } Both of these can rightly be considered the equivalent of friend in C#. Methods that are protected are already available to derived classes.
I think you are looking for internal. This page has a pretty comprehensive comparison of VB/C#. As others have said, though, subclasses do have access to protected methods so you should already see them.
1) Internal is the C# equivelant of the VB. NET 'friend' keyword, as you have guessed (as opposed to a replacement) 2) Usage is as follows internal void Function() {} internal Class Classname() {} internal int myInt; internal int MyProperty { get; set; } 3) It, basically, is an access modifier that stipulates that the accessibility of the class / function / vairiable / property marked as internal is as if it were public to the Assembly it is compiled in, and private to any other assemblies.
Internal is the equivalent of friend. A protected method is only available within the same class or from an inheritor. If you're trying to expose protected methods from an inheritor, you can wrap them in public methods.
No, "internal" is not the same as "friend" (at least the C++ 'friend') friend specifies that this class is only accessible by ONE, particular class. Internal specifies that this class is accessible by ANY class in the assembly.
Your subclass will be able to access the protected members of the class you inherit. Are you looking to give access to these protected members to another class?
If you create a class on the same project as the source code you've received, and you don't inherit the source code's classes, yet you want have access to those protected methods, make those methods internal. But if you want to purely inherit the the class(be it on same project or different one), no need to change those protected to internal. You can merrily inherit the class and have access those protected methods at the same time.
That being said, there's a reason why some of the methods in the source code you've received has protected access on methods instead of internal/friend. Methods are marked as protected to allow 3rd party developers who inherits from those class and let them have an access on those methods(protected) even they are in binary form (i.e. DLL).
"internal" is the equivalent of VB's "Friend" keyword.  Members marked internal can be accessed from within the assembly, but not outside of the assembly.  Members marked 'internal protected' can be accessed from within the assembly in addition to classes within or without the assembly inheriting from the class.
If you're talking about the C++ "friend" keyword - there is no equivalent. If you have inherited from a base class, you should be able to access all the protected methods from the inheriting class. Therefore you should not need any "friend" equivalent!
You can access the protected method within the subclasses but not outside the scope of the subclass, for example :1    class Program 2    { 3        static void Main(string args) 4        { 5            SubClass sub = new SubClass(); 6            sub.Test(); 7        } 8 9        public class BaseClass 10        { 11            protected virtual void Test() 12            { 13                Console. WriteLine("Testing Time"); 14            } 15        } 16 17        public class SubClass : BaseClass 18        { 19            public new void Test() 20            { 21                base.Test(); 22            } 23        } 24    } Your base class Test method cannot be accessed in the Program class because it is accessible only in sub classes. The only way is to create a public method in your sub class to abstract your base class protected methods if you need to call them outside of their boundary.Agility.
What is the equivalant of a 'friend' keyword in C Sharp? How do I use the 'internal' keyword? I have read that 'internal' keyword is a replacement for 'friend' in C#.
I am using a dll in my C# project that I have the source code for and yet I do not want to modify the existing code. I have inherited the class and I can use my inherited class any way I want. The problem is that most of the code in the parent class has protected methods.
Will using a friend somehow make it possible to access or call these protected methods? Protected methods are not accessible through instance objects. Â Is that where you are having trouble?
Mark the best replies as answers. If you have inherited from a base class, you should be able to access all the protected methods from the inheriting class. Therefore you should not need any "friend" equivalent!
Does the same hold true for a private method? If you have inherited from a base class, you should be able to access all the protected methods from the inheriting class. Therefore you should not need any "friend" equivalent!
Does the same hold true for a private method?  "Private" means exactly that.  The member's access remains within the class where it was declared.
  C# Access ModifiersMark the best replies as answers. If you have inherited from a base class, you should be able to access all the protected methods from the inheriting class. Therefore you should not need any "friend" equivalent!
Does the same hold true for a private method?  "Private" means exactly that.  The member's access remains within the class where it was declared.
Mark the best replies as answers. "Fooling computers since 1971." So, in the parent class, I need to change the 'private' methods to 'internal'?
If you wish to have derived classes to have access to members of your base class---your "parent" class? ---then you must not declare them as private. Â Private means exactly that, private.
 No one else should be able to access it. This is a link --->  C# Access Modifiers ---- to a help page that explains it all. Mark the best replies as answers.
You need to change "private" to "protected".
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.