小编Kon*_*rad的帖子

mongodb C#exception无法从BsonType Int32反序列化字符串

我是新手在C#中使用mongo db,但我试图在mongo db中导入大型数据库.MyDb包含仅具有简单参数Id,Body,Title Tags的实体.

这是mongo中的实体示例.

{
"Id" : "someff asdsa",
"Title" : "fsfds fds",
"Body ": "fsdfsd fs",
"Tags" : "fsdfdsfsd"
}
Run Code Online (Sandbox Code Playgroud)

这是我在C#中的mongoEntity类

 [BsonIgnoreExtraElements]
    class Element
    {
        [BsonId]
        public ObjectId _id { get; set; }
        [BsonElement("Id")]
        public string Id { get; set; }
        [BsonElement("Title")]
        public string Title { get; set; }
        [BsonElement("Body")]
        public string Body { get; set; }
        [BsonElement("Tags")]
        public string Tags { get; set; }

        public void ShowOnConsole()
        {
            Console.WriteLine(" _id {0} Id {1} Title {2} Body {3} …
Run Code Online (Sandbox Code Playgroud)

c# mongodb

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

如何将毫秒转换为秒.

我必须把我的秒表"变量"变成秒?

Stopwatch czasAlg = new Stopwatch(); 
czasAlg.Start();
//Do semothing
czasAlg.Stop();
Decimal Tn = czasAlg.ElapsedMilliseconds/(decimal)n;
Run Code Online (Sandbox Code Playgroud)

c# stopwatch

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

正则表达式只匹配两个特定单词,例如是或否

我的尝试是:

^Yes|^No|^$ 
Run Code Online (Sandbox Code Playgroud)

但是当我使用它时,"是"和"否"以外的词匹配

我如何解决它?

我一直在使用这个在线正则表达式测试器测试我的正则表达式.

regex

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

选择不同的mongodb C#

我必须从简单的mongo db数据库中选择不同的记录.我有很多简单的记录,这些记录看起来像这样:

{"word":"some text"}
Run Code Online (Sandbox Code Playgroud)

我的代码非常简单.

    const string connectionString = "mongodb://localhost";
    var client = new MongoClient(connectionString);

    MongoServer server = client.GetServer();
    MongoDatabase database = server.GetDatabase("text8");
    MongoCollection<Element> collection = database.GetCollection<Element>("text8");
    MongoCursor<Element> words = (MongoCursor<Element>)collection.FindAll();
Run Code Online (Sandbox Code Playgroud)

但我不知道如何从数据库中选择不同的单词.有人可以给我一些建议吗?

c# mongodb

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

C#heapSort,System.Timers; 检查算法时间

我必须在C#中检查HeapSort算法时间,我的问题是我知道我必须使用System.Timers,因为我不知道如何测量算法时间.我必须检查表的算法时间,包含1000,10 000,100 000和1000 000个整数.

请帮助我好人.

这是代码:


    using System;

namespace Sort
{
    class Program
    {
        public static void Adjust(int[] list, int i, int m)
        {
            int Temp = list[i];
            int j = i * 2 + 1;

            while (j <= m)
            {
                if (j < m)
                    if (list[j] < list[j + 1])
                        j = j + 1;
                if (Temp < list[j])
                {
                    list[i] = list[j];
                    i = j;
                    j = 2 * i + 1;
                }
                else
                {
                    j = m …
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)

c# timer heapsort

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

C#与构造函数的奇怪问题

我有三个参数构造函数的恕我直言非常奇怪的问题,当我尝试运行程序时,visual studio只显示一个错误:"'Sort.HeapSort'不包含一个带有3个参数的构造函数112 35".

namespace Sort
{
    class HeapSort
    {
        private int[] A;
        private int heapSize;
        private int min; 
        private int max; 
        Random myRandom = new Random(); 

        HeapSort(int size, int min1, int max1) //this is the three argument constructor.
        {
            heapSize = size - 1;
            min = min1;
            max = max1;
            A = new int[size];
        }    
    }

    class Program
    {
        static void Main(string[] args)
        {
            int size = 30;
            int min = 0;
            int max = 100;

            HeapSort myHeapSort = new …
Run Code Online (Sandbox Code Playgroud)

c# constructor

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

Umbraco CMS无法保存模板

我在visual studio中设置了一个新的umbraco项目,任何预装的模板,当我试图添加新的母版页时我无法保存它,我可以在visual studio中编辑它但我不能保存umbraco后端的任何变化.任何消化来解决我的问题?

umbraco savechanges

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

标签 统计

c# ×5

mongodb ×2

constructor ×1

heapsort ×1

regex ×1

savechanges ×1

stopwatch ×1

timer ×1

umbraco ×1