首先我要说的是,我是一个新手,对 C# 的了解很少。
回到主题:我需要制作一个能够对非常大的整数进行加/减的程序。最初,使用 BigInt 只是发现它是不允许的。应该有一个合乎逻辑的解决方法吗?我有一个想法,使用“小学方法”,从右到左添加每个数字。
我制作了一个字符串,将其拆分为 char 数组,并从右到左添加每个数字(GetUpperBound-i)。但这似乎不起作用。
我的代码:
string s, s2;
char[] c_arr, c_arr2;
int i, erg;
s = "1234";
s2 = "5678";
c_arr = s.ToCharArray();
c_arr2 = s2.ToCharArray();
for (i = 0; i <= c_arr.GetUpperBound(0); i++)
{
erg = c_arr[c_arr.GetUpperBound(0)-i]+c_arr2[c_arr2.GetUpperBound(0)-i];
Console.Write(erg);
}
Console.ReadKey();
Run Code Online (Sandbox Code Playgroud) 使用async方法签名以及await在这些方法中使用表达式有什么其他限制,如果有的话?到目前为止,我知道标记的方法async只能有以下返回类型之一(可能还有更多?).
voidTaskTask<TResult>我想在Window Form C#中增加DateTimePicker中的字体大小.我想在DateTime选择器中设置最小14到16的字体大小.
我试过下面的代码,但它不起作用.
dateTimePicker1.CalendarFont = new Font("Courier New", 8.25F, FontStyle.Italic, GraphicsUnit.Point, ((Byte)(0)));
Run Code Online (Sandbox Code Playgroud) 我试图检查一个数字是负数而不使用比较运算符.我试图检查最重要的一点.我正在做以下事情:
int x = -5;
Console.WriteLine(x >> 31);
Run Code Online (Sandbox Code Playgroud)
我期待输出1.但我明白了-1.什么解释了这种行为?
我正在尝试删除符合条件的IDictionary对象中的所有元素.
例如,IDictionary包含一组键和相应的值(比如说80个对象).键是字符串,值可以是不同类型(想想使用directshow从wtv文件中提取元数据).
一些键包含文本"thumb",例如thumbsize,startthumbdate等.我想删除IDictionary中包含单词thumb的所有对象.
我在这里看到的唯一方法是使用.Remove方法手动指定每个键名.
有没有办法让所有对象包含单词thumb的对象,并将它们从IDictionary对象中删除.
代码如下所示:
IDictionary sourceAttrs = editor.GetAttributes();
Run Code Online (Sandbox Code Playgroud)
GetAttributes定义为:
public abstract IDictionary GetAttributes();
Run Code Online (Sandbox Code Playgroud)
我无法控制GetAttributes,它返回一个IDictionary对象,我只是通过在调试时查看它来了解内容.(可能是HashTable)
更新:感谢Tim的最终答案:
sourceAttrs = sourceAttrs.Keys.Cast<string>()
.Where(key => key.IndexOf("thumb", StringComparison.CurrentCultureIgnoreCase) == -1)
.ToDictionary(key => key, key => sourceAttrs[key]);
Run Code Online (Sandbox Code Playgroud) 我需要知道是否可以通过 C# 应用程序调用系统配置的特定选项卡。
到目前为止,我只能msconfig.exe通过我的代码进行调用,即
ProcessStartInfo pf = new ProcessStartInfo(
Path.Combine(Environment.SystemDirectory, "msconfig.exe"));
pf.Verb = "runas";
Process.Start(pf);
Run Code Online (Sandbox Code Playgroud)
现在我只想调用单个选项卡来打开StartUp单击按钮的选项卡。请给我一些解决方案。
我有一个 List
List<Myclass> li = new List<Myclass> ();
Run Code Online (Sandbox Code Playgroud)
这里Myclass是
public class Myclass
{
public string ExamName { get; set; }
public Nullable<decimal> Marks { get; set; }
public Nullable<decimal> OutOfMarks { get; set; }
public string GradeMarks { get; set; }
public Nullable<decimal> markEaxmTotalOverAll { get; set; }
public Nullable<decimal> MarksExamTotalMarksTypeWise { get; set; }
public Nullable<decimal> MarksExamOutOfMarksTotalOverAll { get; set; }
public Nullable<decimal> MarksExamOutOfMarksTotalMarksTypeWise { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
li包含近10000个项目
我想markEaxmTotalOverAll在所有10000个项目中将值设置为50
但不想用循环来做,有没有办法更新它,我试过这个代码
li.Select(s => { …Run Code Online (Sandbox Code Playgroud) 预先警告,我刚开始学习Python,这是我第一次在这个网站上学习.如果我的行为像n00b,请不要讨厌.
所以我创建了一个程序,它应该告诉你以光速和光速的因素来到达星(指定距离)需要多长时间.它从一个名为easygui的库开始,它创建了一个很好的窗口,用户可以选择一个因子.他们选择的因素成为变量"选择".这部分代码工作正常.理想情况下,该值将被输入到一个函数中,该函数将进行分解,并返回行程天数的值.这是不成功的.最有可能的是,我只是设置错了,所以如果有人知道使用函数的正确方法,我真的很感谢你的帮助!哦,我试着疯狂地评论,所以希望一切都有意义!
import easygui as eg #the gui creation library I am using
dist = 41000000000000 #distance to the star
light = 300000 #speed of light
def Convert (factor): #takes in factor chosen by user
speed = light*factor #the speed is the factor multiplied by the speed of light
time = (dist/speed)/3600 # the time is the distance/divided by the speed, since thats a huge value in seconds, the /3600 should reduce it to days
return time #"should" return the …Run Code Online (Sandbox Code Playgroud) 例如=> iddaa ///news/haber05112013.jpg
结果=> iddaa/news/haber05112013.jpg
我想替换这个特殊字符("/"); 但有时双字符('///'),有时('//')可以替代它?谢谢
我正在尝试将朱利安日期字符串转换为日期时间,但网络上的解决方案似乎都不起作用。我有一个儒略日期字符串13324。
Julian Date: 13324
Run Code Online (Sandbox Code Playgroud)
我想得到以下日期时间
Date: 20-Nov-2013
Run Code Online (Sandbox Code Playgroud)
您能指导我正确的方向吗?谢谢。