전체 글
-
비동기 방식의 파일 복사(async)c# 2017. 5. 7. 17:39
private async Task CopyAsync(string fromPath, string ToPath) { btnSyncyCopy.Enabled = false; long totalCopied = 0; using (FileStream fromStream = new FileStream(fromPath, FileMode.Open)) { using (FileStream toStream = new FileStream(ToPath,FileMode.Create)) { byte[] buffer = new byte[1024 * 1024]; int nRead = 0; while ((nRead= await fromStream.ReadAsync(buffer,0,buffer.Length))!=0) { await toStr..
-
파일 다루기2c# 2017. 5. 6. 16:31
Stream stream1 = new FileStream("a.dat",FileMode.Create) //새파일 생성Stream stream2 = new FileStream("a.dat",FileMode.Open) // 파일 열기Stream stream3 = new FileStream("a.dat",FileMode.OPenCreate) //파일을 열거나 없으면 생성해서 열기Stream stream4 = new FileStream("a.dat",FileMode.Turncate) // 파일을 비워서 열기Stream stream5 = new FileStream("a.dat",FileMode.Append) // 덧붙이기 모드로 열기 1.Stream using System;using System.Collectio..
-
파일 다루기1c# 2017. 5. 6. 14:39
File,Diretory: 정적 메소드 제공, 한 두가지 기능을 다룰때 FileInfo, DirectoryInfo : 인스턴트 메소드 제공 기능 File FileInfo 생성 FileStream fs=File.Create("a.dat") FileInfo file = new FileInfo("a.dat") FileStram fs = file.Create(); 복사 File.Copy("a.dat","b.dat") FileInfo src = new FileInfo("a.dat"); FlleInfo des = src.Copy(To"b.dat"); 삭제 File.Delete("a.dat") FileInfo file = new FIleInfo("a.dat")file.Delete(); 이동 FIle.Move("a.d..
-
out:출력 전용 매개변수c# 2017. 5. 6. 12:03
out는 참조형 변수 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace UsingOut{ class Program { static void Divide(int a, int b, out int quo, out int rem) { quo = a / b; rem = a % b; } static void Main(string[] args) { int a = 30; int b = 3; int c; int d; Divide(a, b, out c, out d); Console.WriteLine("a:{0}, b:{1}, a/b:{2}, a%b:{3}"..
-
데이터 타입c# 2017. 5. 6. 11:55
Nullable형식 :변수에 값이 할당 되지 않으면 null을 할당하세요.데이터형식? 변수이름: int ?a =null; ------------------int? a = null; Console.WriteLine(a.Hasvalue) ; // FasleConsole.WriteLine(a !=null); // False a=3; Console.WritLine(a.HasValue); //TrueConsole.WriteLine(a != null) //TrueConsole.WriteLine(a.value) //3 Var형식-Compile가 자동으로 변식 형식을 지정해 줍니다.-var형식은 반드시 선언과 함께 초기화 해 주어야 합니다.-var형식은 반드시 지역변수로만 사용할 수 있습니다. var a =3;var ..
-
LINQ-조인c# 2017. 5. 6. 11:29
내부조인 : -기준 데이터A, 비교 데이터 중, A와 B의 교집합-기준데이터 A에 존재하지만 B에 존재하지 않은 데이터는 조인된 결과에서 누락 됩니다. from a in Ajoin b in B on a.XXX equals b.YYYY 외부조인: 외부 조인은 기본데이터에 들어 있는 모든 데이터는 포함되어 있다. using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace Join{ class Program { class Profile { public string Name { get; set; } public int Height { get; set; }..
-
LINQ-Group BYc# 2017. 5. 6. 10:38
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace GroupBy{ //group A by B into C //A는 from절에서 뽑아낸 변수 B는 분류 기준 C는 그룹변수 //Igrop class Program { class Profile { public string Name { get; set; } public int Height { get; set; } } static void Main(string[] args) { Profile[] arrProfile = { new Profile() {Name="정우성",Height=180 }, ne..
-