小编Noe*_*oel的帖子

C#将整数字符串拆分为IEnumerable <int>

我需要将一串逗号分隔的整数转换为整数列表.

做这个的最好方式是什么?

我可以在下面做,但我担心性能 - 有更好的更有效的方法来做到这一点?

public IEnumerable<int> GetListOfIds()
{
    string Ids = "1,4,5,7,12"; // would be passed into method
    List<int> _result = Ids.Split(',')
                           .ToList()
                           .Select(item => int.Parse(item))
                           .ToList();

    return _result;
}
Run Code Online (Sandbox Code Playgroud)

c# syntax parsing

4
推荐指数
1
解决办法
8574
查看次数

在Graphite中组织度量存储?

如何在根级别保存我的指标.目前已保存在统计信息层次结构下(参见graphite)想要保存在顶层(Graphite)

graphite

4
推荐指数
2
解决办法
937
查看次数

.net标准2.0和System.Security.Cryptography.ProtectedData.Protect

查看System.Security.Cryptography.ProtectedData.Protect @ https://docs.microsoft.com/en-gb/dotnet/api/

因为我们希望将一个库从4.7移植到.net标准2.0库,其中.net core 2.0将使用它.所以我进行了搜索,它只能在完整的框架和.net核心中使用

我的问题是为什么在.Net Stanard 2.0中没有它?

我会教它是否可以用于例如4.7和.net core 2.0那么它将成为.Net Standard 2.0的一部分

.net-core .net-standard-2.0

4
推荐指数
2
解决办法
4783
查看次数

哪个Ruby版本适用于Windows上的Watir?

我应该在Windows环境中使用什么版本的Ruby?

我试图在1.9上使用Watir并且它不起作用.将工作在1.8.6.

有关使用哪个版本的任何建议以及Watir在1.9上不起作用的原因

ruby windows watir

3
推荐指数
1
解决办法
2184
查看次数

通过 f# 中的展平将数组的数组缩减为单个数组

如果我有以下内容

type Merchant = {
    Id:int;
    OtherItems:int[] }


let (merchant1:Merchant) = {
    Id = 1;
    OtherItems = [| 1; 2 |]}

let (merchant2:Merchant) = {
    Id = 2;
    OtherItems = [| 1; 2 |]}


let merchants = [| merchant1;merchant2|]
Run Code Online (Sandbox Code Playgroud)

我想扁平化到以下,我该怎么做?

Id = 1 OtherItems 1  
Id = 1 OtherItems 2 
Id = 2 OtherItems 1  
Id = 2 OtherItems 2
Run Code Online (Sandbox Code Playgroud)

这是我想出的,但似乎无法进一步

let x = 
    merchants
     |> Array.map(fun merchant -> merchant, merchant.OtherItems)
Run Code Online (Sandbox Code Playgroud)

注意:我可以用 C# oo 风格做很长的事情,但想使用函数式方式

f#

3
推荐指数
1
解决办法
467
查看次数

签署API请求时要包含的内容

如果我有一个作为API请求发送的复杂对象(例如下面的Order),我应该在生成签名时包含所有属性还是仅使用一个子集?

我问,因为我不清楚,从查看其他API的请求参数是扁平和简单的

public class Order
    {
        public string Id { get; set; }
        public string ClientIdentifier { get; set; }
        public IEnumerable<OrderItems> OrderItems { get; set; }
        public long timestamp { get; set; }
        public string signature { get; set; }
    }

public class OrderItems
{
    public string ItemId { get; set; }
    public string Name { get; set; }
    public IEnumerable<decimal> PriceBands { get; set; }pes
            more types



}

and so on ....
Run Code Online (Sandbox Code Playgroud)

c# authorization oauth

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

ArrayList和IEnumerable查询

为什么以下DisplayContents对于ArrayList不起作用(不会编译),因为它继承了IEnumerable的形式)

public class Program
    {
        static void Main(string[] args)
        {
            List<int> l = new List<int>(){1,2,3};
            DisplayContents(l);

            string[] l2 = new string[] {"ss", "ee"};
            DisplayContents(l2);

            ArrayList l3 = new ArrayList() { "ss", "ee" };
            DisplayContents < ArrayList>(l3);

            Console.ReadLine();
        }

        public static void DisplayContents<T>(IEnumerable<T> collection)
        {
            foreach (var _item in collection)
            {
                Console.WriteLine(_item);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c#

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

c#6主要人员

我有以下两个班级

public class Point(int x, int y)
    {
        public int X { get; } = x;
        public int Y { get; } = y;
    }



    public class Point2
    {
        public int X { get; private set; }
        public int Y { get; private set; }

        public Point2(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
Run Code Online (Sandbox Code Playgroud)

并使用jetbrains dotpeek我在反编译时得到以下内容:

namespace ConsoleApplication1
{
  public class Point
  {
    public int X
    {
      get
      {
        return this.\u003CX\u003Ek__BackingField;
      }
    }

    public int …
Run Code Online (Sandbox Code Playgroud)

c# c#-6.0

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

输入所需的注释

我有以下内容:

let GetDateTime() = System.DateTime.UtcNow


let InternalHandle dependencies =
    let getDateTime = dependencies

    let future = getDateTime()
    let future = getDateTime().AddDays(float 5)
    printf "The time is %A" future
    ()



let Handle() =
    let dependencies = (GetDateTime)

    InternalHandle dependencies


Handle();;
Run Code Online (Sandbox Code Playgroud)

但我的编译错误"getDateTime().AddDays(float 5)"关于类型注释.

我需要做些什么才能让它发挥作用?

getDateTime是一个函数,我不能添加类型注释.

我很困惑为什么它没有拿起它返回DateTime的函数,因此像AddDays这样的所有函数都可用

f#

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