Quantcast
Viewing all articles
Browse latest Browse all 9

Answer by ankit for internal vs public in C#

In a very simple language:

Internal : you will only able to access within a assembly.for ex: if you have created a AccountService.csproj with internal class

public interface IAccount{  int TotalAmount(long accountID);}internal class Account:IAccount{  public int TotalAmount(long accountID){       ...   }}public class Customer{ public long accountID {get;set;} public int GetTotalAmount(){   IAccount account = new Account();   return account.TotalAmount(accountID) }}

if you are referring AccountService.csProj to BankService.csProj (BankService.csProj --> AccountService.csproj)

Below are the properties that accessible in BankService.csProj    Customer.GetTotalAmount() -- AccessibleIAccount.TotalAmount()    -- AccessibleAccount.TotalAmount()     -- Not Accessible (as account class is internal)

Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>