我有一个static包含路径的字段的类。
public static class PfadSammlung
{
public static string Path_Example = @"C:\temp";
}
Run Code Online (Sandbox Code Playgroud)
如何在NLog.Config文件中使用此路径来指定目标的文件名?
public static class PfadSammlung
{
public static string Path_Example = @"C:\temp";
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。
我正在使用c#在Windows窗体应用程序中工作.我有两个字段,形式为"用户名"和"密码",两个按钮"登录"和"取消".在表单加载光标放在用户名文本框中,这是好的.
但是当我TAB从键盘上按下而不是转到密码文本框时,它会转到"登录"按钮.我怎么设置这个?
此外,选择所有文本的快捷方式 CTRL+ A在文本字段中不起作用.有帮助吗?
我试图在我的linq代码中添加一个动态where子句.但是我收到以下错误.其他样本提供相同的代码但它们工作正常,所以我不确定我是否错过了什么.
var toBeReturn = db.estimate.ToList();
if(sname != null)
{
toBeReturn = toBeReturn.Where(x => x.estimate_status == sname);
}
Run Code Online (Sandbox Code Playgroud)
错误:
严重级代码说明项目文件行抑制状态错误CS0266无法将类型"System.Collections.Generic.IEnumerable"隐式转换为"System.Collections.Generic.List".存在显式转换(您是否错过了演员?)
请帮忙
我需要提供一个解决方案来查找字符串数组中的最短字符串.我当时认为应该比较每个字符串的长度才能返回.
这是我被困的地方
static void Main(string[] args)
{
//find the shortest string in an array of string
string[] names = new string[3]{
"Tom", "and", "jerry"
};
foreach(string name in names){
Console.Write(name + ", ");
}
Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我比较部分并解释它
我想将价格(加倍)四舍五入到最接近的xx.99
例如:
10.3 ==> 10.99
10 ==> 10.99
10.97 ==> 10.99
10.50 ==> 10.99
10.99 ==> 10.99
10.01 ==> 10.99
我做了Math.Round,Math.Truncate,Math.Ceiling但它不能正常工作的情况下所有.我可以转换string,拆分和替换,但我认为这不是一个好方法.
我能怎么做?
有什么区别:
public List<MyType> Something{ get; set; } = new List<MyType>();
Run Code Online (Sandbox Code Playgroud)
和
public List<MyType> Something{
get{
return new List<MyType>();
}
//set...
}
Run Code Online (Sandbox Code Playgroud)
上下文:
我不确定我在代码中看到的行为.构造函数null上有一个服务,但在未来的方法调用中,我假设的是类的相同实例.
需要做什么的示例:

"输入了几个数字(输入再次以0结尾).确定并打印第5个,第10个,第15个数字的总和等."
有人可以告诉我我的代码有什么问题吗?
class Program
{
static void Main(string[] args)
{
int counter = 0;
int sum = 0;
Console.Write("Enter a number: ");
int number = int.Parse(Console.ReadLine());
while (number != 0)
{
if (number > 0 && counter % 5 == 0)
{
counter++;
sum = sum + number;
}
Console.Write("Enter a number: ");
number = int.Parse(Console.ReadLine());
}
Console.WriteLine("Sum of the 5th, 10th, 15th ... number is = {0}", sum);
Console.ReadKey();
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下类层次结构:
public class SportPlan
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<Record> RecordFields { get; set; }
}
public class Record
{
public Guid Key { get; set; }
public string Alias { get; set; }
public List<Value> Values { get; set; }
}
public class Value
{
public int Index { get; set; }
public List<DayOfWeek> DaysOfWeek { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我需要SportPlan.RecordFields按dayOfWeek(.NET enum)过滤并Value使用 …
我有一个带有动态添加控件的表单。当用户单击 next 时,必须删除所有动态控件。我的代码只删除了其中的一些。
例如dtxt2,第一次不会被删除,但如果我第二次运行删除功能,它会被删除。
这是添加动态的函数:
void TextboxesStep21()
{
removeDynamics();
TextBox dtxt1 = new TextBox();
dtxt1.Name = "DynamicTextBox1";
dtxt1.Location = new System.Drawing.Point(336, 125);
dtxt1.Text = ((diameterOfDrivingWeel + spindleSlope)*10).ToString();
this.Controls.Add(dtxt1);
TextBox dtxt2 = new TextBox();
dtxt2.Name = "DynamicTextBox2";
dtxt2.Location = new System.Drawing.Point(336, 148);
dtxt2.Text = gearingRatioDen.ToString();
this.Controls.Add(dtxt2);
TextBox dtxt3 = new TextBox();
dtxt3.Name = "DynamicTextBox3";
dtxt3.Text = gearingRatioNum.ToString(); ;
dtxt3.Location = new System.Drawing.Point(336, 171);
this.Controls.Add(dtxt3);
pictureBox1.SendToBack();
pictureBox2.SendToBack();
}
Run Code Online (Sandbox Code Playgroud)
这是我的删除功能
void removeDynamics()
{
foreach (Control x in this.Controls)
{
if (x.Name.Contains("Dynamic")) …Run Code Online (Sandbox Code Playgroud)