Xóa bài viết
Bạn có chắc chắn muốn xóa bài viết này không ?
Xóa bình luận
Bạn có chắc chắn muốn xóa bình luận này không ?
C# Internal Access Specifiers
Encapsulation C#
C# Internal Access Specifiers
The internal access specifier
- Các class và object từ namespace khác sẽ không thể nhìn thấy its member variables and methods
- The variable or classes mà khai báo với internal có thể truy cập từ bất kì thành viên trong cùng ứng dụng. Nó là the default access specifier cho 1 class trong C# programming
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Vu_Hong_Anh
{
class access
{
// Biến string khai báo kiểu internal
internal string name;
public void print()
{
Console.WriteLine("\nMy name is " + name);
}
}
class Program
{
static void Main(string[] args)
{
access ac = new access();
Console.Write("Enter your name:\t");
// Accepting value in internal variable
ac.name = Console.ReadLine();
ac.print();
Console.ReadLine();
}
}
}
Output:
Enter your name: Vu Hong Anh
My name is Vu Hong Anh
Bình luận

{{ comment.user.name }}
Bỏ hay
Hay

Cùng một tác giả

1
3
Tạo form mới khi click vào nút button trong C https://www.youtube.com/watch?v=LWoE7P4RHFM content VuQuangAnh 02112018
Bài viết liên quan

0
5
fCC: Technical Documentation Page note So I have finished the HTML part of this exercise and I want to come here to lament about the lengthy HTML ...

4
0
I used Spring boot, Hibernate few times back then at University, I'v started using it again recently. In this (Link), I want to check how Spring J...

24
1
Toán tử XOR có tính chất: + A XOR A = 0 + 0 XOR A = A Với tính chất này, có thể cài đặt bài toán sau với độ phức tạp O(N) về runtime, và với O(1)...