例如,如果我开始学习Haskell,我可以发现自己使用它.我听说这种语言的一些常见用途是功能性的吗?
鉴于以下代码和此问题中给出的建议,我决定修改这个原始方法,并询问IEnumarable中是否有任何值返回它,如果没有返回没有值的IEnumerable.
这是方法:
public IEnumerable<Friend> FindFriends()
{
//Many thanks to Rex-M for his help with this one.
//https://stackoverflow.com/users/67/rex-m
return doc.Descendants("user").Select(user => new Friend
{
ID = user.Element("id").Value,
Name = user.Element("name").Value,
URL = user.Element("url").Value,
Photo = user.Element("photo").Value
});
}
Run Code Online (Sandbox Code Playgroud)
由于一切都在return语句中,我不知道如何做到这一点.会这样的吗?
public IEnumerable<Friend> FindFriends()
{
//Many thanks to Rex-M for his help with this one.
//https://stackoverflow.com/users/67/rex-m
if (userExists)
{
return doc.Descendants("user").Select(user => new Friend
{
ID = user.Element("id").Value,
Name = user.Element("name").Value,
URL = user.Element("url").Value,
Photo = user.Element("photo").Value
});
}
else
{ …Run Code Online (Sandbox Code Playgroud) 我有这个代码,我怎么能让它接受所有典型的图像格式?PNG,JPEG,JPG,GIF?
这是我到目前为止所拥有的:
public void EncryptFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
dialog.InitialDirectory = @"C:\";
dialog.Title = "Please select an image file to encrypt.";
if (dialog.ShowDialog() == DialogResult.OK)
{
//Encrypt the selected file. I'll do this later. :)
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,过滤器设置为.txt文件.我可以改为PNG,但其他类型呢?
private string[] ColeccionDeCortes(string Path)
{
DirectoryInfo X = new DirectoryInfo(Path);
FileInfo[] listaDeArchivos = X.GetFiles();
string[] Coleccion;
foreach (FileInfo FI in listaDeArchivos)
{
//Add the FI.Name to the Coleccion[] array,
}
return Coleccion;
}
Run Code Online (Sandbox Code Playgroud)
我想将其转换FI.Name为字符串,然后将其添加到我的数组中.我怎样才能做到这一点?
如何使用C#和.NET 3.5/4优雅地完成这项工作?
例如,数字可以在1到100之间.
我知道一个简单的就足够了; 但这个问题的关键词是优雅.这是我的玩具项目不是为了生产.
这个问题不是关于速度,而是关于代码美.停止谈论效率等等; 记住你正在向合唱团讲道.
所以我开始像Python一样,但我遇到麻烦...运行它.大声笑
我现在正在使用IDLE,但它没有任何用处,因为你一次只能运行几行.
我也使用Komodo Edit来创建实际的.py文件.
我的问题是,如何运行.py文件来测试实际的程序?
我正在使用Windows 7和Komodo Edit 5作为我的IDE.在Komodo按F5并没有做任何事情.

我什么时候应该使用其中一种?
我想在我的应用程序中使用的所有文件(图像,声音,xml文件等)都在.exe文件中,所以我不会使用一堆文件夹和文件进行部署.
谢谢(你的)信息.
例如,要做出蓝色的东西我会去:
this.BackColor = Color.LightBlue;
Run Code Online (Sandbox Code Playgroud)
我如何召唤控制色,卡其色.
谢谢你.
public void LoadAveragePingTime()
{
try
{
PingReply pingReply = pingClass.Send("logon.chronic-domination.com");
double AveragePing = (pingReply.RoundtripTime / 1.75);
label4.Text = (AveragePing.ToString() + "ms");
}
catch (Exception)
{
label4.Text = "Server is currently offline.";
}
}
Run Code Online (Sandbox Code Playgroud)
目前我的label4.Text得到类似的东西:"187.371698712637".
我需要它来表示:"187.34"
DOT后只有两个帖子.有人可以帮我吗?