小编xpo*_*ort的帖子

我们什么时候需要将UseShellExecute设置为True?

//
// Summary:
//     Gets or sets a value indicating whether to use the operating system shell
//     to start the process.
//
// Returns:
//     true to use the shell when starting the process; otherwise, the process is
//     created directly from the executable file. The default is true.
[DefaultValue(true)]
[MonitoringDescription("ProcessUseShellExecute")]
[NotifyParentProperty(true)]
public bool UseShellExecute { get; set; }
Run Code Online (Sandbox Code Playgroud)

如果我们生成一个新进程,我们什么时候需要将UseShellExecute设置为True?

c#

121
推荐指数
3
解决办法
8万
查看次数

75
推荐指数
6
解决办法
9万
查看次数

为什么扩展方法只允许在非嵌套的非泛型静态类中使用?

为什么扩展方法只允许在非嵌套的非泛型静态类中使用?在嵌套的通用静态类中考虑扩展方法是没用的吗?

c#

32
推荐指数
2
解决办法
5873
查看次数

在DOS批处理中调用更改目录后如何返回原始目录?

我想创建一个批处理文件batch.bat,它接受2个必需参数:

  • %1 表示相对于当前目录的路径.
  • %2 代表一个flaname.

假设当前目录是father\me\.

用户可以按如下方式使用此批次:

  • batch child/grandchild log
  • batch ../brother log

职位描述batch.bat如下.

  1. 移动到%1目录,
  2. 迭代*.tex目录中的所有文件%1.
  3. 移动前将结果保存在目录中.

以下是不完整的代码:

rem batch.bat takes 2 arguments.
cd %1
dir /b *.tex > <original directory>\%2.txt
Run Code Online (Sandbox Code Playgroud)

在DOS批处理中调用更改目录后如何返回原始目录?

dos batch-file

27
推荐指数
3
解决办法
2万
查看次数

使用uint而不是int作为数据模型类中的主键是否是个好主意?

我们知道主键通常是正整数.

在数据模型类中使用uint而不是int作为主键是否是个好主意?

示例:

public class Customer
{
   public uint CustomerId {get;set;}
   //others are omitted for the sake of simplicity.
}
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

22
推荐指数
3
解决办法
3920
查看次数

在Find,Single,First中,哪一个最快?

我想最小化从列表中检索单个唯一元素所需的时间.哪一个是最快的方法Find,SingleFirst?请注意,搜索键是唯一的ID.

c#

20
推荐指数
2
解决办法
8236
查看次数

是否可以创建无法复制的文件?

为了限制范围,假设我们仅在Windows世界中.

还假设我们不想使用权限策略.

我们可以创建一个无法复制的文件吗?

先感谢您.

windows

12
推荐指数
3
解决办法
2万
查看次数

如何使用DisplayForModel()显示Customers列表?

通常我们分别使用DisplayForModelEditorForModel显示和编辑单个Customer对象.

如何使用这些模板方案显示客户列表?

asp.net-mvc

12
推荐指数
1
解决办法
2万
查看次数

在代码中使用'"using"关键字时,我应该在哪里捕获异常?

哪一个结构更好?

class Program
{
    static void Main(string[] args)
    {
        try
        {
            using (Foo f = new Foo())
            {
                //some commands that potentially produce exceptions.
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

要么...

class Program
{
    static void Main(string[] args)
    {

        using (Foo f = new Foo())
        {
            try
            {
                //some commands that potentially produce exceptions.
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

c# performance exception-handling

11
推荐指数
2
解决办法
763
查看次数

如何从ConfigureServices()中访问CreateDefaultBuilder()提供的IConfiguration?

我通常会做以下事情

static void Main()
{
    IConfiguration config = new ConfigurationBuilder()
                        .SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile("appsettings.json", false, true)
                        .Build();

    Host.CreateDefaultBuilder()
        .ConfigureServices(isc =>
        {
            isc.AddSingleton(config);

            isc.AddDbContext<DbContext>(options =>
            {
                options.UseSqlServer(config.GetConnectionString("Duplicate"));
            });
        })                
        .Build();
}
Run Code Online (Sandbox Code Playgroud)

appsettings.json我只知道已经提供了配置CreateDefaultBuilder(),所以我认为我应该能够按如下方式简化我的代码。

static void Main()
{
    Host.CreateDefaultBuilder()
        .ConfigureServices(isc =>
        {
            isc.AddDbContext<DbContext>(options =>
            {
                options.UseSqlServer(********.GetConnectionString("Duplicate"));
            });
        })                
        .Build();
}
Run Code Online (Sandbox Code Playgroud)

问题

********如何获取默认提供的配置?

c# .net-core asp.net-core

11
推荐指数
1
解决办法
3838
查看次数