是否可以使用System.IO.Path类或一些类似的对象来格式化unix样式路径,提供与PATH类类似的功能?例如,我可以这样做:
Console.WriteLine(Path.Combine("c:\\", "windows"));
Run Code Online (Sandbox Code Playgroud)
这表现了:
"C:\\windows"
Run Code Online (Sandbox Code Playgroud)
但我是否尝试使用正斜杠(/)类似的东西它只是为我反转它们.
Console.WriteLine(Path.Combine("/server", "mydir"));
Run Code Online (Sandbox Code Playgroud)
这表现了:
"/server\\mydir"
Run Code Online (Sandbox Code Playgroud) 使用以下sytax是否有任何开销:
Form1 myForm = new Form1();
myForm.Show();
Run Code Online (Sandbox Code Playgroud)
相反:
Form1 myForm;
myForm = new Form1();
myForm.Show();
Run Code Online (Sandbox Code Playgroud)
当我学习VB6时,我被告知在VB中使用quivelent有一个开销 - 在.NET中也是如此吗?
有人可以告诉我,我对以下Linq查询做错了吗?我正在尝试找到具有最高aphanumerical值的目录.
DirectoryInfo[] diList = currentDirectory.GetDirectories();
var dirs = from eachDir in diList
orderby eachDir.FullName descending
select eachDir;
MessageBox.Show(dirs[0].FullName);
Run Code Online (Sandbox Code Playgroud)
编辑:
上面的代码没有编译,编译器生成的错误是:
Cannot apply indexing with [] to an expression of type 'System.Linq.IOrderedEnumerable<System.IO.DirectoryInfo>
Run Code Online (Sandbox Code Playgroud) 我有以下枚举
public enum TESTENUM
{
Value1 = 1,
Value2 = 2
}
Run Code Online (Sandbox Code Playgroud)
然后我想用它来比较我有的整数变量,如下所示:
if ( myValue == TESTENUM.Value1 )
{
}
Run Code Online (Sandbox Code Playgroud)
但是为了做这个测试,我必须按如下方式强制转换枚举(或者可能将整数声明为类型枚举):
if ( myValue == (int) TESTENUM.Value1 )
{
}
Run Code Online (Sandbox Code Playgroud)
有没有办法可以告诉编译器枚举是一系列整数,这样我就不必执行此操作或重新定义变量?
我创建了一个新的VS 2010可扩展性包.到目前为止,我想要做的就是让用户按下按钮并使用解决方案的全部内容填充列表视图.我有以下代码:
EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");
foreach (Project project in dte.Solution.Projects)
{
foreach(ProjectItem pi in project.ProjectItems)
{
listView1.Items.Add(pi.Name.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎工作,但是,它填充与包装解决方案的内容的列表中它并没有这个运行时启动实验实例.我是否错误地实例化了引用?
我有一个Windows应用商店应用程序,可以创建辅助磁贴.单击磁贴时,我希望应用程序执行,实际上是一个离线功能(也就是说,我不想回到应用程序,但希望应用程序执行某些操作然后退出).因此,在这种情况下,我想启动电子邮件客户端,例如.这是我到目前为止的地方:
app.addEventListener("activated", function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.arguments !== "") {
// Activation arguments are present that
// were declared when the secondary tile was pinned to Start.
args.setPromise(WinJS.UI.processAll().done(function () {
var emailaddress = args.detail.arguments;
var promise = Email.SendNewMail.sendEmail(emailaddress);
//promise.complete();
return;
}));
} else if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
// TODO: This application has been newly launched. Initialize
// your application here.
} else {
// TODO: This application has been reactivated from suspension.
// Restore …Run Code Online (Sandbox Code Playgroud) javascript microsoft-metro windows-8 winjs windows-store-apps
我有多个项目正在访问相同的设置(它们是一个项目,但我正在重新分解).我想做的是相当于:
"Add Existing Item" -> "Add Link"
Run Code Online (Sandbox Code Playgroud)
这些项目是C#和VB的混合体.当我尝试添加链接时,它确实带来了设置文件,但它无法识别它.我在尝试加载设置时遇到错误:
Error HRESULT E_FAIL has been returned from a call to a COM component.
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉项目使用特定的设置文件(在IDE内部或外部)?
我在TFS2013版本上遇到以下错误:
TF900547: The directory containing the assemblies for the Visual Studio Test Runner is not valid ''.
Run Code Online (Sandbox Code Playgroud)
看这里,这似乎是这个问题的答案是改变从VS测试运行到MSTest的测试运行.但是,当我尝试在构建定义中编辑测试运行时,测试运行器选项被设置为Visual Studio Test Runner灰色.什么决定了这个框中显示的内容,以及如何添加MSTest?
我已经安装了VS2012代理服务器上的处理试验.
是否可以根据linq查询的结果建立一个位掩码; 例如:
class MyClass
{
public int Flag{get;set;}
public bool IsSelected {get;set;}
}
myVar = GetlistMyClass();
int myFlag = myVar.Where(a => a.IsSelected).Select(?);
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
var result = MessageBoxHelper.MsgBox
.ShowAsync("Press Yes to proceed", MessageBoxButton.YesNo)
.ContinueWith((answer) =>
{
if (answer.Result == MessageBoxResult.Yes)
{
Task<bool> asyncTask = ExecuteAsyncFunc();
//asyncTask.Unwrap(); ??
asyncTask.ContinueWith((a) =>
{
// More
}, TaskContinuationOptions.OnlyOnRanToCompletion);
}
}, TaskContinuationOptions.OnlyOnRanToCompletion);
}
Run Code Online (Sandbox Code Playgroud)
在其他地方调用是这样的:
public async Task<bool> ExecuteAsyncFunc()
{
await CallAnotherAsyncFunction();
}
Run Code Online (Sandbox Code Playgroud)
我相信我需要调用 Unwrap(),我已经尝试过,因为我在块内调用 wait ContinueWith()。但是,当我取消注释时,出现以下错误:
错误 CS1929“任务”不包含“展开”的定义,并且最佳扩展方法重载“TaskExtensions.Unwrap(Task)”需要“任务”类型的接收器
我是否需要在这种情况下使用 Unwrap?如果需要,我做错了什么?