C\#6.0 의 속성(Property)의 문법 과 초기 값 에 대한 상세 한 설명
데이터베이스 에 표 한 장 만 들 기:

CREATE TABLE [dbo].[ToolLocation]
(
[ToolLocation_nbr] SMALLINT IDENTITY(1,1) NOT NULL PRIMARY KEY,
[LocationName] NVARCHAR(20) NOT NULL,
[Description] NVARCHAR(50) NULL,
[IsActive] BIT NOT NULL DEFAULT(1)
)
GO
Source Code
앞 뒤 대비 와 쓰기:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Insus.NET.Models
{
public class ToolLocation
{
public short ToolLocation_nbr { get; set; } = 1;
public string LocationName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public bool IsActive { get; set; } = true;
}
}
Source Code
다음 Insus.NET 에서 실 체 를 만 드 는 것 을 보 여 줍 니 다.
using Insus.NET.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Insus.NET.Entities
{
public class ToolLocationEntity
{
public IEnumerable<ToolLocation> ToolLocations()
{
return new List<ToolLocation>() {
new ToolLocation(),
new ToolLocation { ToolLocation_nbr = 2, LocationName = "A2", Description = "A2 CNC",IsActive = true},
new ToolLocation { ToolLocation_nbr = 3, LocationName = "C4", Description = "C4 CNC",IsActive = false}
};
}
}
}
Source Code
세 개의 대상 이 있 을 것 입 니 다.첫 번 째 대상 은 기본 값 을 사용 하 는 것 입 니 다.컨트롤 러 에서:

ASP.NET MVC 보기에 서 이 데 이 터 를 표시 합 니 다.

실행 효과 보기:

이상 의 C\#6.0 의 속성(Property)의 문법 과 초기 값 에 대한 상세 한 설명 은 바로 편집장 이 여러분 에 게 공유 한 모든 내용 입 니 다.여러분 께 참고 가 되 고 저 희 를 많이 사랑 해 주 셨 으 면 좋 겠 습 니 다.