반응형

Java만 열심히 하다가 C# 만질일이 있어서 만지던중


다차원 배열 초기화를 하다가 멘붕에 빠졌습니다. '-' ;;;;;;;


'-' 이런 모양의 초기화도 존재할수 있따니!!!! ㅋㅋㅋ 옛날 사람




// Two-dimensional array.
int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
// The same array with dimensions specified.
int[,] array2Da = new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
// A similar array with string elements.
string[,] array2Db = new string[3, 2] { { "one", "two" }, { "three", "four" },
                                        { "five", "six" } };

// Three-dimensional array.
int[, ,] array3D = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } }, 
                                 { { 7, 8, 9 }, { 10, 11, 12 } } };
// The same array with dimensions specified.
int[, ,] array3Da = new int[2, 2, 3] { { { 1, 2, 3 }, { 4, 5, 6 } }, 
                                       { { 7, 8, 9 }, { 10, 11, 12 } } };

// Accessing array elements.
System.Console.WriteLine(array2D[0, 0]);
System.Console.WriteLine(array2D[0, 1]);
System.Console.WriteLine(array2D[1, 0]);
System.Console.WriteLine(array2D[1, 1]);
System.Console.WriteLine(array2D[3, 0]);
System.Console.WriteLine(array2Db[1, 0]);
System.Console.WriteLine(array3Da[1, 0, 1]);
System.Console.WriteLine(array3D[1, 1, 2]);

// Getting the total count of elements or the length of a given dimension.
var allLength = array3D.Length;
var total = 1;
for (int i = 0; i < array3D.Rank; i++) {
    total *= array3D.GetLength(i);
}
System.Console.WriteLine("{0} equals {1}", allLength, total);




출처 : http://msdn.microsoft.com/ko-kr/library/2yd9wwz4.aspx



반응형
반응형

C# 의 다중폼 구성중에서 


Main 폼외에 상위 폼을 띄웠을경우 

아래의 Main 폼을 선택하여 또 폼을 띄우면 계속 새 폼이 뜹니다. 


상위 폼이 떴을경우에 Main  폼이 선택되지 않게 하기 위해서 



private void Button1_Click(object sender, EventArgs e)

 {

            Form2 showform = new Form2();

            showform.show();

 }


위와 같은 코드를



private void Button1_Click(object sender, EventArgs e)

 {

            Form2 showform = new Form2();

            showform.ShowDialog();

 }


로 바꾸시면 됩니다. 





참 쉽죠?






반응형
반응형



static public bool JsonDataContainsKey(JsonData data,string key) { bool result = false; if(data == null) return result; if(!data.IsObject) { return result; } IDictionary tdictionary = data as IDictionary; if(tdictionary == null) return result; if(tdictionary.Contains(key)) { result = true; } return result; }




LitJSON의 JsonData 에 해당 key가 존재하는지 체크하는 함수



출처 : https://gist.github.com/sinergy/5626704








반응형
반응형





버튼 클릭시


익스플로러 창이 뜨면서 내가 원하는 홈페이지로 이동하기!


간단하게

한줄만 추가하면 됩니다 ^ㅡ^








ShellExecute( this->m_hWnd, TEXT( "open" ), TEXT( "IEXPLORE.EXE" ), TEXT(" Http://doswlf.tistory.com "), NULL, SW_SHOW );


유용하게 사용하세요 ^ㅡ^ 꾸벅




반응형
반응형

오랜만에 프로그래밍 관련 포스팅이군요 ^^



어제 프로그램을 짜다가 문득 써먹게 되어서


아 이걸 팁으로 포스팅 해야겠구나 ~


생각하게 됐습니다.


#pragma comment() <-- 요놈은


라이브러리 추가시에 가장 많이 쓰임니다.


간혹가다가 api프로젝트에서 디버깅을 위해 콘솔창을 띄우고 싶을때는
#pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console" )


이렇게 linker 을 쓰기도 하지만.


주로 프로젝트~ 셋팅~ 들어가서 라이브러리 일일이 추가하기 귀찮으실때


자주 씁니다.









#pragma comment( lib, "msimg32.lib")

이런식으로 씁니다.


비주얼 C++을 쓰면서 많이 쓰진 않지만 예전에는 라이브러리 추가시엔

저놈을 무조건 써야했습니다 ^^


그럼 유용하게 쓰세요.




반응형

+ Recent posts