코드에 줄 번호 표시
메뉴 모음에서 도구 > 옵션 을 차례로 선택합니다. 텍스트 편집기 노드를 확장한 다음, 사용 중인 언어나 모든 언어 를 선택하여 모든 언어에 줄 번호를 켭니다. (또는 검색 상자에 줄 번호 를 입력하고 결과에서 줄 번호 설정/해제 를 선택합니다.)

줄 번호 확인란을 선택합니다.

참고>
줄 번호는 코드에 추가되지 않으며 참조용으로만 사용됩니다.

 

/*
ToInt32(String) 의 예외처리

예외
FormatException
value가 선택적 부호와 숫자 시퀀스(0~9)로 구성되어 있지 않습니다.

OverflowException
value은(는) MinValue보다 작거나 MaxValue보다 큰 숫자를 나타냅니다.
*/
/*
//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드//오버로드
ToInt32(String)
숫자의 지정된 문자열 표현을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt16)
지정된 16비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt32)
지정된 32비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Single)
지정된 단정밀도 부동 소수점 숫자 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Object, IFormatProvider)
지정된 문화권별 서식 지정 정보를 사용하여, 지정된 개체의 값을 32비트 부호 있는 정수로 변환합니다.

ToInt32(String, IFormatProvider)
지정된 문화권별 서식 지정 정보를 사용하여, 숫자의 지정된 문자열 표현을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(String, Int32)
지정된 기수로 나타낸 숫자에 대한 문자열 표현을 32비트 부호 있는 정수로 변환합니다.

ToInt32(UInt64)
지정된 64비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Object)
지정된 개체의 값을 32비트 부호 있는 정수로 변환합니다.

ToInt32(SByte)
지정된 8비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Int64)
지정된 64비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Int32)
지정된 32비트 부호 있는 정수를 실제 변환 작업 없이 반환합니다.

ToInt32(Int16)
지정된 16비트 부호 있는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Double)
지정된 배정밀도 부동 소수점 숫자 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Decimal)
지정된 10진수 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(DateTime)
이 메서드를 호출하면 InvalidCastException이 항상 throw됩니다.

ToInt32(Char)
지정된 유니코드 문자의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Byte)
지정된 8비트 부호 없는 정수의 값을 해당하는 32비트 부호 있는 정수로 변환합니다.

ToInt32(Boolean)
지정된 부울 값을 해당하는 32비트 부호 있는 정수로 변환합니다.
*/



string[] values = { "One", "1.34e28", "-26.87", "-18", "-6.00",
                    " 0", "137", "1601.9", Int32.MaxValue.ToString() };
int result;

foreach (string value in values)
{
   try {
      result = Convert.ToInt32(value);
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                        value.GetType().Name, value, result.GetType().Name, result);
   }
   catch (OverflowException) {
      Console.WriteLine("{0} is outside the range of the Int32 type.", value);
   }
   catch (FormatException) {
      Console.WriteLine("The {0} value '{1}' is not in a recognizable format.",
                        value.GetType().Name, value);
   }
}
// The example displays the following output:
//    The String value 'One' is not in a recognizable format.
//    The String value '1.34e28' is not in a recognizable format.
//    The String value '-26.87' is not in a recognizable format.
//    Converted the String value '-18' to the Int32 value -18.
//    The String value '-6.00' is not in a recognizable format.
//    Converted the String value ' 0' to the Int32 value 0.
//    Converted the String value '137' to the Int32 value 137.
//    The String value '1601.9' is not in a recognizable format.
//    Converted the String value '2147483647' to the Int32 value 2147483647.

/*특정 윈도우 Application에 Hook F5 Key 메세지 보내기*/

using NoName;
using NoName.Diagnostics;
using NoName.Text;//Encoding
using NoName.Runtime.InteropServices;

class HookingMessage
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int unMsg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
public static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

const UInt32 WM_KEYDOWN = 0x0100;
const int VK_F5 = 0x74;

public void running()
{
IntPtr ____handle_mmm=IntPtr.Zero;
bool ____toggle;

____handle_mmm = FindWindow(null, "CONSOLE.TRIS");
____toggle=PostMessage(____handle_mmm, WM_KEYDOWN, VK_F5, 0 );

if(____toggle==true) Console.WriteLine("PostMessage succ!!");
else Console.WriteLine("PostMessage fail!!");
}
}

class Program
{
public static void Main()
{
HookingMessage nm = new HookingMessage();
nm.running();
}
}



/*
namespace:System
Int To Double -> Convert.ToDouble(int or double)
Double to Int -> Convert.ToInt32(double)
*/

class TrisWidthHeight : Form
{
int titledepth, widthdepth, heightdepth;
public TrisWidthHeight()
{
titledepth = this.Height - this.ClientRectangle.Height;
titlewidth = Convert.ToInt32(Convert.ToDouble(titledepth / 10.0)) * 7
titleheight = Convert.ToInt32(Convert.ToDouble(titledepth / 10.0)) * 4
this.Width = titlewidth;
this.Height = titleheight;
}





using NoName;
using NoName.Timers;

class Program
{
public static void Main()
{
ExampleManageCls nm = new ExampleManageCls();
nm.running();
}
}

class ExampleManageCls
{
Timer tm = new Timer();
DateTime endTime;

public void running()
{
tm.Elapsed += new ElapsedEventHandler(____time_tick);
tm.Interval = 1000;
tm.Start();

endTime = DateTime.Now.AddMinutes(1);

while(true)
{
if(endTime<DateTime.Now)
{
break;
}
}
}

void ____time_tick(object sender, ElapsedEventArgs e)
{
Console.WriteLine(DateTime.Now.ToString() + "/" + endTime.ToString());
}
}

/*RESULT-------------------------------------------------------
2022-03-28 오전 9:56:47/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:48/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:49/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:50/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:51/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:52/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:53/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:54/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:55/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:56/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:57/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:58/2022-03-28 오전 9:57:13
2022-03-28 오전 9:56:59/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:00/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:01/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:02/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:03/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:04/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:05/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:06/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:07/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:08/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:09/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:10/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:11/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:12/2022-03-28 오전 9:57:13
2022-03-28 오전 9:57:13/2022-03-28 오전 9:57:13

D:\tmp\console>
-------------------------------------------------------*/

/*
*상속안할경우 나오는 에러메세지*/


Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

ex12.cs(18,26): error CS0115: 'WindowsFrmManage.ProcessCmdKey(ref NoName.Windows.Forms.Message,
        NoName.Windows.Forms.Keys)': 재정의할 적절한 메서드를 찾을 수 없습니다.
ex12.cs(40,26): error CS0115: 'WindowsFrmManage.WndProc(ref NoName.Windows.Forms.Message)': 재정의할 적절한 메서드를 찾을 수 없습니다.

using NoName;
using NoName.Windows.Forms;

class Program
{
public static void Main(string[] args)
{
Application.Run(new WindowsFrmManage());
}
}
class WindowsFrmManage
{
public WindowsFrmManage() {}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x0100, WM_KEYUP = 0x0101, WM_CHAR = 0x0102, WM_SYSKEYDOWN = 0x0104, WM_SYSKEYUP = 0x0105, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
         switch (keyData.ToString())
{
case "Down"   :
break;
case "Escape" :
Application.Exit();
break;
         default:
             break;
         }
     }
return base.ProcessCmdKey(ref msg, keyData);
}

protected override void WndProc(ref Message m)//sdw_mh12e
{
const int WM_KEYDOWN = 0x0100, WM_KEYUP = 0x0101, WM_CHAR = 0x0102, WM_SYSKEYDOWN = 0x0104, WM_SYSKEYUP = 0x0105, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

base.WndProc(ref m);

switch(m.Msg)
{
case WM_PAINT :
break;
default:
break;
}
}
}


using NoName;
using NoName.Windows.Forms;

class FrmIndex006 : Form
{
public FrmIndex006()
{
Console.WriteLine(">>>>FrmIndex006");
}
}

class FrmIndex007 : FrmIndex006
{
public FrmIndex007()
{
Console.WriteLine(">>>>FrmIndex007");
}
}

class FrmIndex008 : FrmIndex007
{
public FrmIndex008()
{
Console.WriteLine(">>>>FrmIndex008");
}
}

class FrmIndex009 : FrmIndex008
{
public FrmIndex009()
{
Console.WriteLine(">>>>FrmIndex009");
}
}

class FrmIndex010 : FrmIndex009
{
public FrmIndex010()
{
Console.WriteLine(">>>>FrmIndex010");
}
}

class FrmMain : FrmIndex010
{
public FrmMain()
{
Console.WriteLine(">>>>FrmMain");
}
protected override void WndProc(ref Message m)
{
const int WM_KEYDOWN = 0x0100, WM_SYSKEYDOWN = 0x0104, WM_PAINT = 0x000f, WM_SIZE = 0x0005;

base.WndProc(ref m);

try
{
switch(m.Msg)
{
case WM_PAINT :
DialogResult dialogResult = MessageBox.Show(">>Quit OK!!", "Inform",
              MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

if (dialogResult == DialogResult.OK) Application.Exit();
break;
default:
break;
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
/*
D:\tmp\console>sample
>>>>FrmIndex006
>>>>FrmIndex007
>>>>FrmIndex008
>>>>FrmIndex009
>>>>FrmIndex010
>>>>FrmMain

D:\tmp\console>
*/

class Program
{
public static void Main()
{
Application.Run(new FrmMain());
}
}


다형성(polymorphism)은 무엇인가요?

polymorphism에서 poly는 여러, 다양한(many), morph는 변형(change)이나 형태(form)의 의미를 가지고 있습니다. 
사전적 정의로만 살펴보면 "여러가지 형태"를 나타내는데, 이를 객체 지향 프로그래밍으로 끌고 온다면 "하나의 객체가 여러 개의 형태를 가질 수 있는 능력"이라 말할 수 있습니다. 


우리는 이미 다형성을 접해본 적이 있습니다. 다형성의 일부인 메소드의 오버로딩(이는 ad-hoc polymorphism에 해당)과 오버라이딩(이는 inclusion polymorphism에 해당)에서 말이죠! 
C#도 객체 지향 프로그래밍에 근간을 두고 있으므로 이 다형성이라는 개념은 자주 사용됩니다.

+ Recent posts