小编san*_*ngh的帖子

在asp.net中使用doPostBack函数

我想在我的链接中使用doPostBack功能.当用户点击它时,它不会重定向到另一个页面,页面将回发.我正在使用此代码,但它不起作用.我在哪里想念?

< a id="Sample" href="javascript:__doPostBack('__PAGE','');">



 function __doPostBack(eventTarget, eventArgument)

  {
           var theform = document.ctrl2

           theform.__EVENTTARGET.value = eventTarget

           theform.__EVENTARGUMENT.value = eventArgument

           theform.submit()
       }
Run Code Online (Sandbox Code Playgroud)

javascript asp.net

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

c#中的通用列表和静态变量行为

我在C#中有一个简单的应用程序.当我运行代码时,我没有得到预期的结果?.我得到2,2,1但我期待1,2,3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            MyList<int> list1 = new MyList<int>();
            MyList<int> list2 = new MyList<int>();
            MyList<double> list3 = new MyList<double>();
            Console.WriteLine(list1.GetCount());
            Console.WriteLine(list2.GetCount());
            Console.WriteLine(list3.GetCount());
        }
    }
    public class MyList<T>
    {
        static int _count;
        public MyList()
        {
            _count++;
        }
        public int GetCount()
        {
            return _count;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

使用Linq列出<Type>的词典列表

我在c#中有以下代码片段

public class Client
{
    public string ID { get; set; }
    public string Name { get; set; }
    public string Address { get; set; }
}




var liste = new List<Dictionary<string, string>>();
            var dictionary = new Dictionary<string, string>();
            dictionary["Id"] = "111";
            dictionary["Name"] = "XYZ";
            dictionary["Address"] = "Addd";
            liste.Add(dictionary);
            var result = liste.SelectMany(x => x);

            //Code for Converting result into List<Client>
Run Code Online (Sandbox Code Playgroud)

现在我想使用linq从结果查询中创建List

c# linq

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

在Object和ValueType类中实现的GetHashCode有什么区别?

我在下面的代码片段中总结了我的问题

struct Point
{
    public int X;
    public int Y;

    public Point(int x, int y)
    {
        this.X = x;
        this.Y = y;
    }

    public override int GetHashCode()
    {
        return base.GetHashCode();
    }

    public void PrintValue()
    {
        Console.WriteLine(
            "{0},{1}",
            this.X, this.Y);
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的struct是从包含GetHashCode方法的ValueType派生的.下面是一个派生自Object和包含GetHashCode方法的类版本.

class Point
{
    public int X;
    public int Y;

    public Point(int x, int y)
    {
        this.X = x;
        this.Y = y;
    }

    public override int GetHashCode()
    {
        return base.GetHashCode();
    }

    public void PrintValue()
    {
        Console.WriteLine(
            "{0},{1}", …
Run Code Online (Sandbox Code Playgroud)

c#

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

使用c#并行下载多个文件

我想用C#并行下载文件.为此,我编写了这个代码,它运行得很好,但问题是UI很冷.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace FileDownloader
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private static int count = 1;
        private static string f= "lecture";
        private string URL = "www.someexample.com";

        public MainWindow()
        {
            InitializeComponent();
        }

        public …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library

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

C#增量运算符(++)问题:为什么输出错误?

我有一个简单的c#控制台应用程序,但我输错了为什么?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11
{
class Program
{
    static void Main(string[] args)
    {
        int i = 100;
        for (int n = 0; n < 100; n++)
        {
            i = i++;
        }
        Console.WriteLine(i);
    }

}
}
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
3
解决办法
7864
查看次数

为什么将相同的两个数字转换为Object使它们不相等?

我有以下代码片段但输出错误.

class Program
    {
        static void Main(string[] args)
        {
            var i = 10000;
            var j = 10000;
            Console.WriteLine((object) i == (object) j);


        }
    }
Run Code Online (Sandbox Code Playgroud)

我期待的是真的,但我变得虚伪

c#

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

添加两个短变量[C#]时编译时间错误

可能重复:
整数加总蓝调,短+ =短问题

我已将我的问题总结为以下代码片段.我有两个短变量,我将这两个变量添加到另一个短变量中,但我得到编译时错误.为什么会这样?

 1.short x = 1, y = 1;
 2.short z = x + y;   
Run Code Online (Sandbox Code Playgroud)

在第2行编译时间错误 编辑:

If short+short=int

then why int+int !=long
Run Code Online (Sandbox Code Playgroud)

c#

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

不同的访问修饰符的属性?

我有疑问,我们可以在属性中获取和设置不同的访问修饰符.

谢谢,

c# asp.net

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

Page.IsPostBack或IsPostBack

我只是想知道这两个陈述之间是否有任何性能差异

Page.IsPostBack
Run Code Online (Sandbox Code Playgroud)

要么

IsPostBack
Run Code Online (Sandbox Code Playgroud)

asp.net

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

标签 统计

c# ×8

asp.net ×3

javascript ×1

linq ×1

task-parallel-library ×1