0
메서드가 예외를 throw 할 때 ReadKey() 메서드가 작동하지 않습니다? 프로그램이 실행될 때 ReadKey 메서드는 메서드 dos가 예외를 throw하지 않는 경우에만 작동합니다. 메서드가 예외를 throw하면 콘솔 창이 두 번째 또는 두 번째로 나타납니다. 여기 응용 프로그램이 예외를 throw 할 때 ReadKey 메서드가 작동하지 않습니다.
은 방법 :#region Using directives
using System;
#endregion
namespace ParamsArray
{
class Util
{
public static int Sum(params int[] paramList)
{
if (paramList == null)
{
throw new ArgumentException("Util.Sum: null parameter list");
}
if (paramList.Length == 0)
{
throw new ArgumentException("Util.Sum: empty parameter list");
}
int sumTotal = 0;
foreach (int i in paramList)
{
sumTotal += i;
}
return sumTotal;
}
}
} 여기
가 Program.cs#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
namespace ParamsArray
{
class Program
{
static void DoWork()
{
Console.WriteLine(Util.Sum(null));
Console.ReadKey();
}
static void Main()
{
try
{
DoWork();
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
}
}
} 메소드가 예외를 throw하면