Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Project 1:
- Base class:
- public abstract class BaseRepository
- {
- private protected Task<string> GetEmail(int id)
- {
- return Task.FromResult("username@mail.com");
- }
- }
- Inheritance works!
- public class AccountRepository : BaseRepository
- {
- public async Task UpdateEmail(int id, string newEmail)
- {
- var currentEmail = await GetEmail(id);
- }
- }
- # Project 2:
- Inheritance fails with error: "BaseRepository.GetEmail(int) is inaccessible due to its protection level"
- public class CustomerRepository : BaseRepository
- {
- public async Task UpdateCustomer(int id, string newEmail)
- {
- var currentEmail = await GetEmail(id);
- }
- }
- #Note:
- Using [assembly: InternalsVisibleTo("Project2") in AssemblyInfo.cs of "Project1" will of course make the method visible.
Add Comment
Please, Sign In to add comment