블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2814)
Unity3D (868)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (236)
협업 (61)
3DS Max (3)
Game (12)
Utility (140)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

[링크] https://overworks.github.io/unity/2018/08/30/finding-best-string-concatenation.html

 

그때는 맞고 지금은 틀리다 - 문자열 연결 시에 가장 효율적인 방법은 StringBuilder가 아닐 수도 있

StringBuilder.AppendFormat()에 대한 설명에 잘못된 점이 있어 수정했습니다. (2018.9.1)

overworks.github.io

 

반응형
Posted by blueasa
, |

[참고]

.net에서 제공하는 음력 캘릭더는 한국/중국/일본/태국 4개 캘린더가 있다.

그 나라에 맞는 캘린더를 잘 확인하자.

 

[링크] https://cooldragon.tistory.com/33

 

[C#] 양력 / 음력 변환

출처 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=18&MAEULNo=8&no=1228&ref=1228 -------------------------------------------------------------------------------------------------- //양력은 음력으로변환 테스트 private void button1

cooldragon.tistory.com

 

반응형
Posted by blueasa
, |

 

 

RegExLib.com Regular Expression Cheat Sheet (.NET)

   

Character Escapes http://tinyurl.com/5wm3wlEscaped CharDescription

ordinary characters Characters other than . $ ^ { [ ( | ) ] } * + ? \ match themselves.
\a Matches a bell (alarm) \u0007.
\b Matches a backspace \u0008 if in a []; otherwise matches a word boundary (between \w and \W characters).
\t Matches a tab \u0009.
\r Matches a carriage return \u000D.
\v Matches a vertical tab \u000B.
\f Matches a form feed \u000C.
\n Matches a new line \u000A.
\e Matches an escape \u001B.
\040 Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences.) For example, the character \040 represents a space.
\x20 Matches an ASCII character using hexadecimal representation (exactly two digits).
\cC Matches an ASCII control character; for example \cC is control-C.
\u0020 Matches a Unicode character using a hexadecimal representation (exactly four digits).
\* When followed by a character that is not recognized as an escaped character, matches that character. For example, \* is the same as \x2A.

Character Classes http://tinyurl.com/5ck4llChar ClassDescription

. Matches any character except \n. If modified by the Singleline option, a period character matches any character. For more information, see Regular Expression Options.
[aeiou] Matches any single character included in the specified set of characters.
[^aeiou] Matches any single character not in the specified set of characters.
[0-9a-fA-F] Use of a hyphen (–) allows specification of contiguous character ranges.
\p{name} Matches any character in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing.
\P{name} Matches text not included in groups and block ranges specified in {name}.
\w Matches any word character. Equivalent to the Unicode character categories [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \w is equivalent to [a-zA-Z_0-9].
\W Matches any nonword character. Equivalent to the Unicode categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \W is equivalent to [^a-zA-Z_0-9].
\s Matches any white-space character. Equivalent to the Unicode character categories [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v].
\S Matches any non-white-space character. Equivalent to the Unicode character categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v].
\d Matches any decimal digit. Equivalent to \p{Nd} for Unicode and [0-9] for non-Unicode, ECMAScript behavior.
\D Matches any nondigit. Equivalent to \P{Nd} for Unicode and [^0-9] for non-Unicode, ECMAScript behavior.

 

 

[출처] https://regexlib.com/CheatSheet.aspx?AspxAutoDetectCookieSupport=1

 

RegExLib.com Regular Expression Cheat Sheet (.NET Framework)

\p{name}Matches any character in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing.

regexlib.com

 

반응형
Posted by blueasa
, |
I can use the Ctrl+, shortcut to search for methods but will search among the entire project:

This lists all the classes in all files that have this method, and I want to search only in the current file, similar to Alt+M in VAssistX. Is there a shortcut for that?

I found Is there an easy way to jump right to a method within a file?, but it's for VS2012, and they only suggest Ctrl+F or Ctrl+,.

Note: I'm looking for true navigation, not Ctrl+F, and only within the current file, unlike Ctrl+,.

 

 

[출처] https://stackoverflow.com/questions/40306687/find-method-in-current-file-class-in-vs2015-c

 

Find method in current file/class in VS2015/C#

I can use the Ctrl+, shortcut to search for methods but will search among the entire project: This lists all the classes in all files that have this method, and I want to search only in the curren...

stackoverflow.com

 

반응형
Posted by blueasa
, |
    using System.Text.RegularExpressions;
    
    /// <summary>
    /// 닉네임 체크
    /// 글자수 제한 : 1~10
    /// 사용가능 문자 : 숫자/영어소문자/영어대문자/한글/일본어/한자
    /// [정규식]
    /// 숫자 : 0-9
    /// 영어 대소문자 : a-zA-Z
    /// 한글완성형 : 가-힣
    /// 한글자모음 : ㄱ-ㅎㅏ-ㅣ(제외)
    /// 일본어 : [ぁ-ゔ]+|[ァ-ヴー]+[々〆〤]
    /// 한자 : 一-龥
    /// </summary>
    /// <param name="_strInputNickname"></param>
    /// <returns>isMatch</returns>
    public static bool IsValidNickname(string _strInputNickname)
    {
        Regex regex = new Regex(@"^[0-9a-zA-Z가-힣ぁ-ゔァ-ヴー々〆〤一-龥]{1,10}$");
        bool bIsMatch = regex.IsMatch(_strInputNickname);
        if (false == bIsMatch)
        {
            Debug.LogWarningFormat("숫자와 영문 대소문자,한글,일본어,한자만 입력가능합니다.(글자제한1~10)");
        }

        return bIsMatch;
    }

 

반응형
Posted by blueasa
, |

How do I get a Dictionary key by value in C#?

Dictionary<string, string> types = new Dictionary<string, string>()
{
    {"1", "one"},
    {"2", "two"},
    {"3", "three"}
};

 

 

[Answer]

Values do not necessarily have to be unique, so you have to do a lookup. You can do something like this:

var myKey = types.FirstOrDefault(x => x.Value == "one").Key;

If values are unique and are inserted less frequently than read, then create an inverse dictionary where values are keys and keys are values.

 

 

[출처] https://stackoverflow.com/questions/2444033/get-dictionary-key-by-value

 

Get dictionary key by value

How do I get a Dictionary key by value in C#? Dictionary<string, string> types = new Dictionary<string, string>() { {"1", "one"}, {"2", "two&q...

stackoverflow.com

 

[참조] https://miuna3.tistory.com/81

 

C# 사전 Dictionary의 Value 값으로 Key 찾기

Dictionary Dic = new Dictionary() { {"1", "Mon"}, {"2", "Tue"}, {"3", "Thu"} };사전이 위와같이 있다고 가정하자. 현재 Dic 의 키 "1" 은 값 "Mon"을 가지고있다. "Mon"으로 키 "1"을 찾고자 할 때에는 아래와 같이 사용하

miuna3.tistory.com

 

반응형
Posted by blueasa
, |

[에러 로그]

[Exception] ArgumentOutOfRangeException: Year, Month, and Day parameters describe 
            an un-representable DateTime.

----

 

개발을 하면서 연도와 상관없이 날짜(월/일/시/분/초) 비교를 위해 임의로 현재 날짜를 9999년으로 변환하게 해놨는데..

하필 오늘이 2024년 2월 29일 윤일(閏日)이다.

 

2024년 2월 29일에서 연도만 9999년으로 바꾸면서 new DateTime()을 하려니 위 에러가 발생했다.

잘 돌아가나 했던 로직이 윤일(閏日)에 에러가 남..(잘못만든거..)

 

해당 월(Month)에 해당 일(Day)이 있는지 체크하는 함수가 있으니 아래와 같이 체크해보고 처리하던가,

if (DateTime.DaysInMonth(2024,2) == 29)
    dt = new DateTime(2024, 2, 29);

 

아니면 다른 방식으로 처리를 해야 될 것 같다.

 

나의 경우는 연도를 같게 만들고 나머지를 비교하기 위해 무조건 9999년(임의 연도)으로 만들었는데..

에러가 나서 반대로 비교할 DateTime이 9999년이면 현재 연도(DateTime.Now.Year)에 맞추게 변경했다.

 

각자 원하는 방식으로 예외처리를 하면 될 것 같다.

 

[참조] https://stackoverflow.com/questions/11246563/year-month-and-day-parameters-describe-an-un-representable-datetime-exception

 

Year, Month, and Day parameters describe an un-representable DateTime Exception

I'm adding an object to a list within an ASP.NET MVC 3 application using the following code but one of the properties of the object is giving me difficulties. ls.Add(new UserRoleModel { UserRoleId...

stackoverflow.com

 

 

 

반응형
Posted by blueasa
, |

[링크] C# 특정 문자열 삭제, 특정 문자열 교체 Regex.Replace

 

C# 특정 문자열 삭제, 특정 문자열 교체 Regex.Replace

특정 문자열과, 삭제할 단어 혹은 문자가 주어졌을 때, 삭제하거나 교체하는 방법을 알아보도록 하자. 예시 Hello my world! 가 주어졌을 때, o와 y를 제외하고 출력하기 -> Hell m wrld! 기본적인 방법 : R

mentum.tistory.com

 

반응형
Posted by blueasa
, |

String Format for Int [C#]

Integer numbers can be formatted in .NET in many ways. You can use static method String.Format or instance method int.ToString. Following examples shows how to align numbers (with spaces or zeroes), how to format negative numbers or how to do custom formatting like phone numbers.

Add zeroes before number

To add zeroes before a number, use colon separator „:“and write as many zeroes as you want.

[C#]

String.Format("{0:00000}", 15);          // "00015"
String.Format("{0:00000}", -15);         // "-00015"

Align number to the right or left

To align number to the right, use comma „,“ followed by a number of characters. This alignment option must be before the colon separator.

[C#]

String.Format("{0,5}", 15);              // "   15"
String.Format("{0,-5}", 15);             // "15   "
String.Format("{0,5:000}", 15);          // "  015"
String.Format("{0,-5:000}", 15);         // "015  "

Different formatting for negative numbers and zero

You can have special format for negative numbers and zero. Usesemicolon separator „;“ to separate formatting to two or three sections. The second section is format for negative numbers, the third section is for zero.

[C#]

String.Format("{0:#;minus #}", 15);      // "15"
String.Format("{0:#;minus #}", -15);     // "minus 15"
String.Format("{0:#;minus #;zero}", 0);  // "zero"

Custom number formatting (e.g. phone number)

Numbers can be formatted also to any custom format, e.g. like phone numbers or serial numbers.

[C#]

String.Format("{0:+### ### ### ###}", 447900123456); // "+447 900 123 456"
String.Format("{0:##-####-####}", 8958712551);       // "89-5871-2551"

출처 http://www.csharp-examples.net/examples/
반응형
Posted by blueasa
, |

[링크] https://amiandappi.tistory.com/16

 

[C#][.NET framework] Directory.GetFiles() 로 여러 확장자 필터링 하기

지난번 포스팅에서 폴더 내 파일 목록을 가져오는 방법에 대해 공유 했다면 이번엔 복수개의 확장자로 필터링 하는 방법에 대해 포스팅 하려고 한다. var files = Directory.EnumerateFiles("C:\\path", "*.*", S

amiandappi.tistory.com

 

반응형
Posted by blueasa
, |