Programming/c# & winform2020. 9. 28. 11:13

오.. 신기신기..

어떻게 빌드하지?하다가

아무생각 없이 그냥 해당 프로젝트 디렉토리 들어가니 mono develop 아이콘이 똭!

더블 클릭해서 실행하니 mono develop  가 뜨고 빌드 옵션을 Debug에서 Release로 바꾸고

빌드하니

 

띠용.. PE32 executable 이 뜬다.

~/ar/bin/Release$ file *
ar.exe:        PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows
ar.exe.config: XML 1.0 document, UTF-8 Unicode (with BOM) text, with CRLF line terminators
ar.pdb:        Microsoft Rosyln C# debugging symbols version 1.0

 

물론 윈도우에서 프로젝트 파일 자체를 그대로 전송해 왔기 때문에

Deub로 가면 아래와 같이 나오는데 pdb는 메시지가 조금 다른데 exe는 리눅스 상에서 인식하는 포맷이 동일하게 나온다.

~/ar/bin/Debug$ file *
ar.exe:        PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows
ar.exe.config: XML 1.0 document, UTF-8 Unicode (with BOM) text, with CRLF line terminators
ar.pdb:        MSVC program database ver 7.00, 512*115 bytes

 

그나저나 4.7의 모든 것 이라고 해놓고

WPF, WWF 그리고 제한된 WCF 그리고 제한된 ASP.NET 비동기 stack을 제외한... (야이!!!)

Everything in .NET 4.7 except WPF, WWF, and with limited WCF and limited ASP.NET async stack.

[링크 : https://www.mono-project.com/docs/about-mono/compatibility/]

 

WWF는 처음 듣네? 검색해보니 레슬링이 왜 나오냐 ㅠㅠ

Windows Workflow Foundation

[링크 : https://docs.microsoft.com/ko-kr/dotnet/framework/windows-workflow-foundation/]

 

그냥 무난하게 winform으로 작성한건 그럼 리눅스에서 빌드하고 실행이 가능한데

GUI자체는 노가다 하거나 visual studio community에서 하는수 밖에 없나?

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

winform socket  (0) 2020.09.29
c# conditional attribute  (0) 2020.09.29
c# 오버라이드, 하이드, 쉐도우  (0) 2020.09.23
c# 상속  (0) 2020.09.23
c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
Posted by 구차니
Programming/c# & winform2020. 9. 23. 11:33

변수에는 오버라이드 개념이 없고

변수에게 있어서 동일 이름이라 숨겨지는 건 하이드라고 표현하는 듯.

기존의 scope를 다른게 표현 하는 느낌이기도 하고(객체로 확장시키면서)...

조금 더 봐야 할 듯?

 

섀도잉(shadowing)

클래스내 멤버 변수가 멤버 메소드내에 선언한 변수에 의해 가려지는 경우

 

하이딩(hiding)

상속 관계에서 상위 객체의 변수가 하위 객체에서 선언한 변수에 의해 가려지는 경우

 

오버라이드(overriding)

상속 관계에서 상위 객체의 메소드가 하위 객체에서 선언한 메소드에 의해 가려지는 경우

해당 내용에 다음과 같은 설명이 있습니다.

case 2:
When you override a member variable in a child class (actually its hiding, not overriding),
which version of that variable will be called depends on the reference, the object, unlike method lookup. 
 
In your sample code, variable a and b are not actually member variable,
they are class variable since static.
Lets change the sample code a bit,
making the 'a' in class 'A' public and adding some test code in main. 

즉, 변수는 override되는 것이 아니라 hiding되는 것이며 dynamic하게 lookup되는 것이 아닙니다.
한 마디로, B의 a는 A의 a를 그저 hiding하는 것이고 A의 a와는 별개의 변수이며,
getA는 자기가 정의된 시점의 a를 a로 생각하게 됩니다. B의 a에 대해서는 아예 모르죠.

[링크 : https://kldp.org/node/110902]

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

c# conditional attribute  (0) 2020.09.29
mono로 sln 프로젝트 빌드가 되네?  (2) 2020.09.28
c# 상속  (0) 2020.09.23
c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
c# base, is  (0) 2020.09.22
Posted by 구차니
Programming/c# & winform2020. 9. 23. 11:10

sealed 는 java의  final 역활.(더 이상 상속을 할 수 없도록)

 

set, get 키워드

java에서 setter/getter의 축약 문법 느낌?

변수에 대해서 사용하며, set의 경우 value 라는 생략된 인자를 받아서 사용

private string name = "John";
public string Name
{
    get
    {
        return name;
    }
    set
    {
       name = value;
    }
}

// ...
static void Main(string[] args)
{
    MyClass mc = new MyClass();
    Console.WriteLine(mc.Name);
    mc.Name = "Bree";
    Console.WriteLine(mc.Name);
}

[링크 : https://blog.hexabrain.net/142]

 

+

2020.09.29

Effective c#을 읽다 보니 property 라고 표현 함.

[링크 : https://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/classes-and-structs/properties]

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

mono로 sln 프로젝트 빌드가 되네?  (2) 2020.09.28
c# 오버라이드, 하이드, 쉐도우  (0) 2020.09.23
c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
c# base, is  (0) 2020.09.22
c# xml 주석  (0) 2020.09.22
Posted by 구차니
Programming/c# & winform2020. 9. 23. 10:37

국룰을 이렇게 파괴하는 MS 이대로 좋은가?!

아무튼 함수이름들도 죄다 Capitalize 했으니 Main()도 당연한거긴 한데..

하긴 한데.. 꽁기꽁기 하네?

 

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

error CS5001: Program does not contain a static 'Main' method suitable for an entry point

 

아래 코드를 테스트 하는데 너무 단순해서 그런가.. Child()와 Child() : base()의 실행 결과에 차이는 없다.

단순히 명시적으로 해주었을뿐 어짜피 부모 생성자 실행 후 자식 생성자를 실행 하는 것은 변하지 않기 때문일 듯.

using System;

class Program
{
	class Parent
	{
		public Parent() {Console.WriteLine("부모 생성자");}
	}
	
	class Child:Parent
	{
//		public Child() : base()
		public Child()
		{
			Console.WriteLine("자식 생성자");}
	}

	static void Main(string[] args)
	{
		Child child = new Child();
	}
}

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

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

c# 오버라이드, 하이드, 쉐도우  (0) 2020.09.23
c# 상속  (0) 2020.09.23
c# base, is  (0) 2020.09.22
c# xml 주석  (0) 2020.09.22
c# 프로그래밍, 문법 공부(문자열)  (0) 2020.09.22
Posted by 구차니
Programming/c# & winform2020. 9. 22. 17:20

java의 super 키워드와 동일한 느낌?

 

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

[링크 : https://blanedil.tistory.com/2]

[링크 : https://www.tutorialspoint.com/equivalent-of-java-super-keyword-in-chash]

 

+ 2020.09.23

ms 문서에서 보는데 base 아래 this가 있어서 무슨 차이인가 보니..

base는 상속관계에서, this는 클래스내 메소드에서 클래스 변수에 접근할때 사용하는 것으로 범위가 다른 경우에 대해서

서로 다른 용어로 정의를 한 것으로 보인다.

base 키워드는 파생 클래스 내에서 기본 클래스의 멤버에 액세스하는 데 사용됩니다
this 키워드는 클래스의 현재 인스턴스를 가리키며 확장 메서드의 첫 번째 매개 변수에 대한 한정자로도 사용됩니다.

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

 

is는 instanceof에 상응할 듯.

[링크 : https://stackoverflow.com/questions/18147211/c-sharp-is-operator-alternative-in-java/18147246]

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

c# 상속  (0) 2020.09.23
c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
c# xml 주석  (0) 2020.09.22
c# 프로그래밍, 문법 공부(문자열)  (0) 2020.09.22
c# 교과서 표준 입출력 등  (0) 2020.09.21
Posted by 구차니
Programming/c# & winform2020. 9. 22. 16:33

특이한 주석이 존재하네?

/// 일 경우에는 xml 주석인데 몇가지 태그가 존재한다.

어떤 의미로는.. doxygen 을 xml로 해놓은것 같긴한데...

결과물에 어떻게 나오는지 궁금하네?

// Adds two integers and returns the result
/// <summary>
/// Adds two integers and returns the result.
/// </summary>
/// <returns>
/// The sum of two integers.
/// </returns>
/// <example>
/// <code>
/// int c = Math.Add(4, 5);
/// if (c > 10)
/// {
///     Console.WriteLine(c);
/// }
/// </code>
/// </example>
public static int Add(int a, int b)
{
    // If any parameter is equal to the max value of an integer
    // and the other is greater than zero
    if ((a == int.MaxValue && b > 0) || (b == int.MaxValue && a > 0))
        throw new System.OverflowException();

    return a + b;
}

 

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

  [링크 : http://blog.daum.net/clerkurt/251]

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

c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
c# base, is  (0) 2020.09.22
c# 프로그래밍, 문법 공부(문자열)  (0) 2020.09.22
c# 교과서 표준 입출력 등  (0) 2020.09.21
c# 교과서 - 키워드 정리  (0) 2020.09.21
Posted by 구차니
Programming/c# & winform2020. 9. 22. 15:42
ToUpper()
ToLower()
Split()
Trim()
TrimStart()
TrimEnd()
string.Join(delimiter, array)

Console.Clear()
Console.SetCursorPosition()

Console.ReadKey()
ConsoleKeyInfo info;
info.key == ConsoleKey.X
ConsoleKey.UpArrow

 

이 먼가.. 메소드에 Capitalize 한 녀석 떄려야함..

쉬프트 누릐기 쬬~~~~오오오오오낸 짜증남 -_-

 

ReadLine()에 이어서 ReadKey()

그리고 ConsoleKeyInfo 라는 녀석이 추가되었네..

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

c# base, is  (0) 2020.09.22
c# xml 주석  (0) 2020.09.22
c# 교과서 표준 입출력 등  (0) 2020.09.21
c# 교과서 - 키워드 정리  (0) 2020.09.21
c# checked , unchecked  (0) 2020.09.21
Posted by 구차니
Programming/c# & winform2020. 9. 21. 14:41

- printf, scanf()

Console.WriteLine(1/2); // 0, 앞의 숫자로 암시적 캐스팅 되서 결과가 나오는 듯
Console.WriteLine("안녕하세요"[100]); // 에러는 발생하지만 이런식으로 변수가 생성 가능한 듯
Console.WriteLin('가'+'힣'); // 99235 char 형으로 인식해서 숫자로 되는 듯. "가" 로 하면 합쳐지려나?

Console.ReadLine();

 

INT_MAX

int.MaxValue
int.MinValue
long.MaxValue
long.MinValue

 

variable.GetType() // 형을 리턴함 "System.Int32"

 

int.parse("111")
int.ToString()
double_var.ToString("0.00"); // 소수점 두자리 출력하도록 제한

 

time 함수?

DateTime.Now.Year
DateTime.Now.Month
DateTime.Now.Day
DateTime.Now.Hour
DateTime.Now.Minute
DateTime.Now.Second

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

c# xml 주석  (0) 2020.09.22
c# 프로그래밍, 문법 공부(문자열)  (0) 2020.09.22
c# 교과서 - 키워드 정리  (0) 2020.09.21
c# checked , unchecked  (0) 2020.09.21
c#(mono) on ubuntu  (0) 2020.09.21
Posted by 구차니
Programming/c# & winform2020. 9. 21. 14:26

좀 생소한 녀석들이 보이네..

 

일반 키워드
abstract
as - effectc c# 에서는 시작 부분에 cast 대신 쓰라고 나오네?
base
bool
break
byte
case
catch
char
checked
class
const
continue
decimal
default
delegate
do
double
else
enum
event
explicit
extern
false
finally
fixed
float
for
foreach
goto
if
implicit
in
int
interface
internal
is
lock
long
namespace
new
null
object
operator
out
override
params
private
protected
public
readonly
ref
return
sbyte
sealed
short
sizeof
stackalloc
static
string
struct
switch
this
throw
true
try
typeof
uint
ulong
unchecked
unsafe
ushort
using
virtual
void
volatile
while

컨텍스트 키워드
add
alias
ascending
async
await
descending
dynamic
from
get
global
group
into
join
let
orderby
partial
remove
select
set
value
var - js 등의 var와 동일한데 초기에 변수 형태가 정해지면 바꿀순 없음
where
yield

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

c# 프로그래밍, 문법 공부(문자열)  (0) 2020.09.22
c# 교과서 표준 입출력 등  (0) 2020.09.21
c# checked , unchecked  (0) 2020.09.21
c#(mono) on ubuntu  (0) 2020.09.21
c# 변수형  (0) 2020.09.18
Posted by 구차니
Programming/c# & winform2020. 9. 21. 12:13

오버플로우를 컴파일 타임이나 런 타임에 확인하도록 하는 키워드

기본적으로 컴파일 타임에 확인이 되도록 되어있고

런타임 체크에서 checked로 되어 있으면 검사하고 unchecked로 되어 있으며 하지 않도록 되는 듯.

 

checked도 unchecked도 지정하지 않으면 상수가 아닌 식(런타임에 계산되는 식)의 기본 컨텍스트는 -checked 컴파일러 옵션의 값으로 정의됩니다. 기본적으로 이 옵션의 값은 설정되지 않으며 unchecked 컨텍스트에서 산술 연산이 실행됩니다.

상수 식(컴파일 시간에 완전히 계산될 수 있는 식)의 경우 기본 컨텍스트는 항상 checked입니다. 상수 식이 unchecked 컨텍스트에 명시적으로 배치되지 않는 경우 식에 대한 컴파일 시간 계산 중 발생하는 오버플로로 인해 컴파일 시간 오류가 발생합니다.

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

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

 

unchecked 환경을 제거하면 컴파일 오류가 발생합니다. 식의 모든 항이 상수이기 때문에 컴파일 시간에 오버플로가 검색될 수 있습니다.

상수가 아닌 항을 포함하는 식은 컴파일 시간 및 런타임에 기본적으로 확인되지 않습니다. checked 환경을 사용하도록 설정하는 방법에 대한 자세한 내용은 checked를 참조하세요.

오버플로를 확인하는 데 시간이 걸리기 때문에 오버플로 위험이 없는 상황에서는 unchecked 코드를 사용하여 성능을 향상할 수 있습니다. 그러나 오버플로가 발생할 가능성이 있는 경우 checked 환경을 사용해야 합니다.

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

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

c# 교과서 표준 입출력 등  (0) 2020.09.21
c# 교과서 - 키워드 정리  (0) 2020.09.21
c#(mono) on ubuntu  (0) 2020.09.21
c# 변수형  (0) 2020.09.18
c# 에서 hex string을 숫자로 변환하기  (0) 2020.09.15
Posted by 구차니