본문 바로가기

C#39

자바 MessageFormat C#의 String.Format과 유사한 클래스 함수 Java MessageFormat.format("[{0}]{1}", "0 입력 문자열", "1 입력 문자열"); public static String format(String pattern, Object ... arguments) { MessageFormat temp = new MessageFormat(pattern); return temp.format(arguments); } C# String s = String.Format("The current price is {0} per ounce.", pricePerOunce); 2022. 5. 20.
27# C# RestSharp 사용해서 restapi 샘플데이터 만들기 자바로 rest api 만들면서 C#으로 테스트하던 도중 포스팅을 하려 한다. 간단한 자바 rest api 이메일 중복 검사 코드 @PostMapping(value = "/duplicate_email") @ApiOperation(value="이메일 중복검사", notes="회원 가입 시 이메일 중복 확인용.") public String emailDuplicate(@RequestParam(value = "email", required = true) String email) throws Exception { if(StringUtils.isEmpty(email) == true) throw new RestapiInvalidRequestException(CustomErrorCode.Email_Blank, Cust.. 2020. 8. 6.
25# 비트 연산 어떤 숫자를 암호화하기는 낭비고 조금 귀찮게 만들기 위해 비트 연산을 사용하기로 했다. static void Main(string[] args) { int user = 1; int key = 34284388; int crtpograph = user ^ key; Console.WriteLine(crtpograph); int decrpt = crtpograph ^ key; Console.WriteLine(decrpt); int a = 1; var b = a 8; Console.WriteLine(c); Console.Read(); } 내가 채택한 방식은 XOR과 Shift 연산이다. 성능에 대해 찾아봤더니 닷넷 구조상 별 다른 차이는 없는것 같다. 아래는 양형의 실행 결과 AND operator: 797968.. 2019. 10. 11.
24# 서버와 접속 중일 때 자신 포트 찾기 서버에 접속하려면 서버 ip와 포트를 알아야 한다. 그런데 클라이언트에서 자기 포트를 알아야 하는 경우가 생겼는데, 별 다른 글이 없는 도중 양형의 좋은 글을 발견. IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners(); TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections(); foreach (TcpConnectionInformation info in tcpConnections) { if(info.RemoteEndPoi.. 2019. 10. 3.