Programming/c# & winform2020. 10. 15. 11:04

 

[링크 : https://stackoverflow.com/questions/7304693/how-to-parse-markdown-via-c-sharp]

[링크 : https://code.google.com/archive/p/markdownsharp/]

 

 

[링크 : https://github.com/Knagis/CommonMark.NET] 유지보수 하지 않음

[링크 : https://github.com/lunet-io/markdig] markdownsharp 보다 인기 좋음

'Programming > c# & winform' 카테고리의 다른 글

c# 파일 읽어서 string에 넣기  (0) 2020.10.15
csharp webbrowser ctrl  (0) 2020.10.15
c# nullable annotation context와 attribute?  (0) 2020.10.14
mono .net framework 실행  (0) 2020.10.13
.net core/.net framework 컨트롤 차이  (0) 2020.10.13
Posted by 구차니
Programming/c# & winform2020. 10. 14. 10:30

string?는 nullable한 string 변수를 사용하겠다는 의미인데

그냥 빌드하면 다음과 같은 경고를 내뱉는다.

warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

 

이 경우에는 아래와 같이 #nullable 어노테이션 컨텍스트를 이용해서 알려주면 경고가 뜨지 않게 된다.

using System;
using System.IO;

class test
{

static void Main()
{
string manyLines=@"This is line one
This is line two
Here is line three
The penultimate line is line four
This is the final, fifth line.";

using (var reader = new StringReader(manyLines))
{
#nullable enable
    string? item;
    do {
        item = reader.ReadLine();
        Console.WriteLine(item);
    } while(item != null);
}
}
}

[링크 : https://stackoverflow.com/questions/55492214/]

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/nullable-references]

 

특성(attribute)

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/concepts/attributes/]

 

+

내용만 보면. java annotation에 대응되는건 attribute이고

c#의 annotation은 compiler directive에 가까운 것 같기도 하고... 조금 더 찾아봐야겠다.

[링크 : https://stackoverflow.com/questions/553857/]

 

+

#define 처럼 #이니까 directive 맞네 -_-

Posted by 구차니
Programming/c# & winform2020. 10. 13. 14:52

.net framework로 만든 프로그램도 기본 컨트롤을 이용했기에 리눅스/mono 에서 구동이 되긴 한다.

 

 

동일한 파일을 리눅스 mono로 실행한 화면

메뉴는 너무 처참하게 깨지네.. 다 있는것 같지만 레이아웃도 너무 심각하게 깨지고..

Posted by 구차니
Programming/c# & winform2020. 10. 13. 14:45

.net core에는 멀티플랫폼 지원못하는 부분은 제외되다 보니 꽤 많은 컨트롤들이 누락된다.

일단은.. WebBrowser와 SerialPort가 빠지는게 커보인다.

 

 

공용 컨트롤 - WebBrowser

 

메뉴 및 도구 모음 - ToolStripContainer

데이터 - Chart / BindingNavigator / DataSet

구성요소 - BackgroundWorker / DirectoryEntry / DirectorySearcher / EventLog / FileSystemWatcher / MessageQueue / PerformanceCounter / Process / SerialPort / serviceController

 

WPF 상호 운용성

Posted by 구차니
Programming/c# & winform2020. 10. 13. 14:33

메뉴를 넣는데 인터넷 검색해보니

예전 MFC 처럼 메뉴를 클릭클릭하면서 생성해낼수 있을줄 알았는데

안되서 혹시? 라는 마음에 해보니

 

.net core는 메뉴는 생성되지만 개별 메뉴는 일일이 코딩으로 해야 한다면

 

.net framwork는 기존대로 생성이 가능하다.

 

멀티플랫폼 갈게 아니라면 .net core로 굳이 가야 하나 라는 생각이 드네..

'Programming > c# & winform' 카테고리의 다른 글

mono .net framework 실행  (0) 2020.10.13
.net core/.net framework 컨트롤 차이  (0) 2020.10.13
winform 에서 이미지 넣기  (0) 2020.10.12
c# strong type langugae  (0) 2020.10.08
c# delagate 대리자  (0) 2020.10.08
Posted by 구차니
Programming/c# & winform2020. 10. 12. 13:55

VS2019 에서 정상적으로 넣는법은 찾지 못했고

Image 클래스를 이용해 넣은 후 컴파일 하면 자동으로 Form1.resx 파일에 추가되긴 한다.

 

[링크 : https://www.dotnetperls.com/picturebox]

[링크 : https://stackoverflow.com/questions/19910172/how-to-make-picturebox-transparent]

 

+ 2020.10.13

winform .net core로 해서 그런걸까?

'Programming > c# & winform' 카테고리의 다른 글

.net core/.net framework 컨트롤 차이  (0) 2020.10.13
.net core와 .net framework 차이 - winform menustrip  (0) 2020.10.13
c# strong type langugae  (0) 2020.10.08
c# delagate 대리자  (0) 2020.10.08
c# out  (0) 2020.10.07
Posted by 구차니
Programming/c# & winform2020. 10. 8. 08:14

 

c#을 강형 언어라고 봐야 할진 모르겠지만

최소한 strongly typed language 라고 해놨으니.. 그리고 문법적으로도 상당 부분이 c에 비해서

explicit 하지 않고 implcit 하게 변형을 하도록 강제하고 있어 최대한

컴파일 타임에 잡아내도록 해놨으니 같은거라고 봐야 하나 아닌가 조금 고민되네?

 

 

C#은 강력한 형식의 언어입니다.

[링크 : http://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/types/]

 

C# is a strongly typed language.

[링크 : https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/]

 

[링크 : https://ahnheejong.name/articles/types-basic-concepts/]

'Programming > c# & winform' 카테고리의 다른 글

.net core와 .net framework 차이 - winform menustrip  (0) 2020.10.13
winform 에서 이미지 넣기  (0) 2020.10.12
c# delagate 대리자  (0) 2020.10.08
c# out  (0) 2020.10.07
c# 타입? 변수명;  (0) 2020.10.05
Posted by 구차니
Programming/c# & winform2020. 10. 8. 08:13

함수포인터의 문법화라는 느낌

node.js에서 흔하게 사용하던 그 문법

 

그런데 람다가 있는데 굳이 delegate 라는걸 또 표현하는 이유는 좀 모르겠다.

두개가 용도가 다른가?

 

[링크 : http://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/delegates/]

[링크 : https://docs.microsoft.com/ko-kr/dotnet/standard/delegates-lambdas]

 

반대로.. delegate에 대응되는 다른 언어의 용어를 찾아봐야겠다.

'Programming > c# & winform' 카테고리의 다른 글

winform 에서 이미지 넣기  (0) 2020.10.12
c# strong type langugae  (0) 2020.10.08
c# out  (0) 2020.10.07
c# 타입? 변수명;  (0) 2020.10.05
c# using 키워드, 예외처리  (0) 2020.10.05
Posted by 구차니
Programming/c# & winform2020. 10. 7. 17:05

함수 인자로 out을 사용하면 기존의 c 언어에서 포인터로 값을 빼내오듯 사용이 가능하다.

 

OutArgExample() 함수에서도 out 을 이용하여 number 인자는 입력이 아닌 출력으로 사용한다고 명시하고

해당 함수를 호출 할때도 out initializeInMethod 라는 변수가 출력용 변수임을 명시한다.

 

 

int initializeInMethod;
OutArgExample(out initializeInMethod);
Console.WriteLine(initializeInMethod);     // value is now 44

void OutArgExample(out int number)
{
    number = 44;
}

 

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/out-parameter-modifier]

 

기존의 C로 보면 이걸 문법적으로 표현해주는 느낌이다.

int initializeInMethod;
OutArgExample(&initializeInMethod);
Console.WriteLine(initializeInMethod);     // value is now 44

void OutArgExample(int *number)
{
    *number = 44;
}

[링크 : https://dojang.io/mod/page/view.php?id=550]

 

+

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/in-parameter-modifier] in

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/ref] ref

 

+

2020.10.14

unsafe 옵션과 키워드를 사용해서 사용은 가능하다

using System;

class Touttest
{
	static void Main()
	{
		unsafe{
		int initializeInMethod;
		OutArgExample(&initializeInMethod);
		Console.WriteLine(initializeInMethod);     // value is now 44

		void OutArgExample(int *number)
		{
			*number = 44;
		}
		}
	}
}
$ csc /unsafe out2.cs

unsafe 옵션과 키워드를 사용해서 사용은 가능하다

 

 

+

포인터는 기본적으로 막히고..

out2.cs(8,17): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
out2.cs(8,3): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
out2.cs(13,4): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
out2.cs(13,13): error CS0266: Cannot implicitly convert type 'int' to 'int*'. An explicit conversion exists (are you missing a cast?)
out2.cs(13,4): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context
out2.cs(11,22): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context

 

/unsafe 옵션을 주지 않고 빌드하면 경고가 아닌 에러가 발생한다 ㄷㄷ

out2.cs(7,3): error CS0227: Unsafe code may only appear if compiling with /unsafe

'Programming > c# & winform' 카테고리의 다른 글

c# strong type langugae  (0) 2020.10.08
c# delagate 대리자  (0) 2020.10.08
c# 타입? 변수명;  (0) 2020.10.05
c# using 키워드, 예외처리  (0) 2020.10.05
c# @문자열  (0) 2020.10.05
Posted by 구차니
Programming/c# & winform2020. 10. 5. 15:05

발단은.. 여기 이녀석.

string? item;

이게 무언가 했는데... string* item; 처럼 보려고 하니 보이기도 하고?

 

string manyLines=@"This is line one
This is line two
Here is line three
The penultimate line is line four
This is the final, fifth line.";

using (var reader = new StringReader(manyLines))
{
    string? item;
    do {
        item = reader.ReadLine();
        Console.WriteLine(item);
    } while(item != null);
}

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/keywords/using-statement]

 

 

변수가 Nullable<T> 형으로 컴파일러에게 알려주는 역할(?) 라는데..

 

class Program
{
    static void Main(string[] args)
    {
        Int32? x;
        Nullable<Int32> y;
    }
}

[링크 : https://gunnarpeipman.com/csharp-question-marks/]

 

 

 

읽어봐도 무슨 소리인지 모르겠네 ㅠㅠ

형식은 값을 할당 하거나 할당할 수 있는 경우 null을 허용 하는 것으로 간주 됩니다 null . 즉, 형식에 값이 없음을 의미 합니다. 기본적으로와 같은 모든 참조 형식은 nullable 이지만 String 와 같은 모든 값 형식은 Int32 이 아닙니다.

C # 및 Visual Basic에서는 값 형식 다음에 표기법을 사용 하 여 값 형식을 nullable로 표시 합니다 ? . 예를 들어 int? c #에서 또는 Integer? Visual Basic는 할당할 수 있는 정수 값 형식을 선언 null 합니다.

Nullable<T>참조 형식은 의도적으로 null을 허용 하므로 구조체는 값 형식만 nullable 형식으로 사용 하도록 지원 합니다.

Nullable클래스는 구조체를 보완 하도록 지원 합니다 Nullable<T> . Nullable클래스는 nullable 형식의 내부 형식 및 내부 값 형식이 제네릭 비교 및 같음 연산을 지원 하지 않는 nullable 형식 쌍에 대 한 비교 및 같음 연산을 지원 합니다.

[링크 : https://docs.microsoft.com/ko-kr/dotnet/api/system.nullable-1?view=netcore-3.1]

 

 

한글로 봐도 모르는데 영어로 본다고 알리가 있냐!!! ㅠㅠ

A type is said to be nullable if it can be assigned a value or can be assigned null, which means the type has no value whatsoever. By default, all reference types, such as String, are nullable, but all value types, such as Int32, are not.

In C# and Visual Basic, you mark a value type as nullable by using the ? notation after the value type. For example, int? in C# or Integer? in Visual Basic declares an integer value type that can be assigned null.

The Nullable class provides complementary support for the Nullable<T> structure. The Nullable class supports obtaining the underlying type of a nullable type, and comparison and equality operations on pairs of nullable types whose underlying value type does not support generic comparison and equality operations.

[링크 : https://docs.microsoft.com/en-us/dotnet/api/system.nullable?view=netcore-3.1]

 

 

현재까지 결론

string은 NULL이 의미를 지니는 타입이기에 ?를 써서 Nullable class를 사용할 수 있는데

string? item;

은 그냥 nullable string 변수를 선언했다고 보면된다.

 

 

+

정작 빌드해보면 string? 으로 하면 경고가 뜨고 string으로 하면 경고가 안뜨는데 실행결과는 동일하다.

 

Microsoft (R) Visual C# Compiler version 3.6.0-4.20224.5 (ec77c100)
Copyright (C) Microsoft Corporation. All rights reserved.

using.cs(18,11): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

 

먼가 너무 파고들어서 산으로 가는건가? ㅠㅠ

변수 이름 뒤에 null 허용 연산자 !를 사용하여 이 동작을 재정의할 수 있습니다. 예를 들어 name 변수가 null이 아닌 것으로 알고 있는데 컴파일러 경고가 발생하는 경우 다음 코드를 작성하여 컴파일러 분석을 재정의할 수 있습니다.

name!.Length;

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/nullable-references]

'Programming > c# & winform' 카테고리의 다른 글

c# delagate 대리자  (0) 2020.10.08
c# out  (0) 2020.10.07
c# using 키워드, 예외처리  (0) 2020.10.05
c# @문자열  (0) 2020.10.05
winform socket  (0) 2020.09.29
Posted by 구차니