小编pur*_*ppc的帖子

如何将标签中的文本与右侧对齐?

所以这是我的文件标签.如果标签太长,它将离开屏幕,因此我必须滚动.

我尝试了以下属性(单独的时间):

  • RightToLeft 是的
  • ContentAlignment 作为BottomRight或TopRight

但是,它们都没有工作.什么是正确的财产?

文件标签

c# label alignment winforms

24
推荐指数
3
解决办法
7万
查看次数

如何使用streamreader读取csv时跳过第一行

我有以下代码从csv文件中读取值并进行一些处理.我想跳过输入csv文件的第一行,因为它包含头文本,但我想在处理完成后将其添加回去.

List<string> values = new List<string>();
using (StreamReader sr = new StreamReader(filePath))
{
    while (sr.Peek() != -1)
    {
        string line = sr.ReadLine();
        List<string> lineValues = line.Split(',').ToList();
        var tempMinInt = 1;
        var tempValue = 1;
        var tempValInt = Convert.ToInt32(lineValues[4]);
        if (lineValues[3] == "1876")
        {
            if (tempValInt % 60 != 0)
            {
                tempMinInt = (tempValInt / 60) + 1;
                tempValue = tempMinInt * 30;
            }
            else
            {
                tempMinInt = tempValInt / 60;
                tempValue = tempMinInt * 30;
            }
        }
        else if (lineValues[3] …
Run Code Online (Sandbox Code Playgroud)

c# asp.net streamreader

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

如何将MVC 5身份验证添加到Unity IoC?

我正在努力在我的应用程序中实现新的ASP.NET MVC 5开箱即用身份验证.但是当使用Unity作为我的IoC时,我不能使用AccountController的任何部分,因为我给出了错误:

类型IUserStore`1没有可访问的构造函数.

这是我给出的统一设置,在global.asax中调用

public class DependencyConfig
{
    public static void Initialise()
    {
        var container = BuildUnityContainer();

        DependencyResolver.SetResolver(new UnityDependencyResolver(container));
    }

    private static IUnityContainer BuildUnityContainer()
    {
        var container = new UnityContainer();

        // register all your components with the container here
        // it is NOT necessary to register your controllers

        container.RegisterType<IEmployeeRepository, EmployeeRepository>();

        container.RegisterType<ITeamRepository, TeamRepository>();

        container.RegisterType<ICompanyRepository, CompanyRepository>();

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

这是新的AccountController.cs的默认构造函数

public AccountController()
        : this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new BusinessTrackerUsersContext())))
{

}

public AccountController(UserManager<ApplicationUser> userManager)
{
    UserManager = userManager;
}

public AccountController(UserManager<ApplicationUser> userManager) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc asp.net-mvc-5 asp.net-identity

22
推荐指数
2
解决办法
7058
查看次数

无法分配,因为它是方法组C#?

无法分配"AppendText",因为它是"方法组".

public partial class Form1 : Form
{
    String text = "";

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        String inches = textBox1.Text;
        text = ConvertToFeet(inches) + ConvertToYards(inches);
        textBox2.AppendText = text;
    }

    private String ConvertToFeet(String inches)
    {
        int feet = Convert.ToInt32(inches) / 12;
        int leftoverInches = Convert.ToInt32(inches) % 12;
        return (feet + " feet and " + leftoverInches + " inches." + " \n");
    }

    private String ConvertToYards(String inches)
    {
        int yards = Convert.ToInt32(inches) / …
Run Code Online (Sandbox Code Playgroud)

.net c# methods method-group assign

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

如何检查我的数组中是否有重复的值?

所以这是我的阵列.

double[] testArray = new double[10];
// will generate a random numbers from 1-20, too lazy to write the code
Run Code Online (Sandbox Code Playgroud)

我想创建一个搜索循环来检查是否有重复的值.我怎么做?

我宁愿不使用任何特殊的内置方法,因为这是一个小数组.

c# arrays repeat

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

通用嵌套类型中的typeof(T)

我不明白为什么以下行为完全按照它的方式行事.我甚至不知道它是由隐藏还是其他原因造成的.

class A<T>
{

    public class B : A<int>
    {
        public void b()
        {
            Console.WriteLine(typeof(T).ToString());
        }
        public class C : B
        {
            public void c()
            {
                Console.WriteLine(typeof(T).ToString());
            }
        }
        public class D : A<T>.B
        {
            public void d()
            {
                Console.WriteLine(typeof(T).ToString());
            }
        }
    }
}
class Program
{
    static void Main(string[] args)
    {
        A<string>.B.C c = new A<string>.B.C();
        A<string>.B.D d = new A<string>.B.D();
        c.c();
        c.b();
        d.d();
        d.b();
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是:

  1. 为什么在c.c()生成时c.b()生成System.String System.Int32

  2. 为什么d.d()d.b() …

c# generics typeof type-parameter

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

C#XML注释:XML注释中有多少<see ... />引用有用?

在我们公司,我们写了过多的Xml评论.一个典型的方法必须记录如下:

/// <summary>
/// Determines whether this <see cref="IScheduler"/> contains a specific <see cref="ISchedule"/>.
/// </summary>
/// <param name="schedule">The <see cref="ISchedule"/> to locate in this <see cref="IScheduler"/>.</param>
/// <returns>
/// Returns <see langword="true"/> if <paramref name="schedule"/> is found in this <see cref="IScheduler"/>; otherwise, <see langword="false"/>.
/// </returns>
bool Contains(ISchedule schedule);

/// <summary>
/// Removes and <see cref="IDisposable.Dispose"/>s the first occurrence of a specific <see cref="ISchedule"/>
/// from this <see cref="IScheduler"/>.
/// </summary>
/// <param name="schedule">The <see cref="ISchedule"/> to remove from …
Run Code Online (Sandbox Code Playgroud)

c# xml comments

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

即使删除用户,ASP.Net Identity Identity.IsAuthenticated仍然是正确的

我在下面的示例代码后实现了ASP.Net Identity:https: //github.com/rustd/AspnetIdentitySample

在我的实现中,我检查用户是否经过身份验证 - 这是从我的MVC控制器上的FilterAttribute调用的; 这个想法是我想确认他们在提供页面之前仍然是auth'ed.

所以在我的过滤器中,最终会调用以下代码:

_authenticationManager.User.Identity.IsAuthenticated;
Run Code Online (Sandbox Code Playgroud)

_authenticationManager 在这儿:

private IAuthenticationManager _authenticationManager
{
    get
    {
        return _httpContext.GetOwinContext().Authentication;
    }
}
Run Code Online (Sandbox Code Playgroud)

_httpContext被传递到我的identityProvider类的构造函数中.

现在 - 一旦我登录,就按预期_authenticationManager.User.Identity.IsAuthenticated;返回true.

但是,在开发期间,我倾倒并重新播种了我的数据库,而没有添加用户.如此有效,我删除了IdentityUser - 但_authenticationManager.User.Identity.IsAuthenticated;STILL返回true

知道为什么会这样吗?我只能假设它以某种方式检查cookie,而不是实际查看数据库.它是否正确?

或者我搞砸了我的实施.....

c# asp.net-mvc asp.net-identity

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

C#变量或数字范围的数组(例如.1 - 100)

我是C#的新手,而且我正在做一个学校项目,我需要弄清楚如何获得一个变量或数字从1到100的数组而不输入数组中的每个数字,例如int[] numbersArray {1,2,3,4,5,6,7,8,9,10...};因为这需要很长时间时间并不是很高效.

我正在使用C#Visual Studio Express 2010.如果你能为我解答这个问题,对我来说意味着很多.我将在if语句中使用它,如下所示:

if(numbersArray.Contains(numbersInput))
{
    Console.WriteLine("numbersInput was a number from 1 to 100")
}
Run Code Online (Sandbox Code Playgroud)

c# arrays variables visual-studio-2010

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

如何添加对Microsoft.VisualBasic.dll的引用?

using Microsoft.VisualBasic;

Microsoft.VisualBasic.Interaction.InputBox("Favourite RPG?", "Game", "Cool!");
Run Code Online (Sandbox Code Playgroud)

那么这样做基本上就是询问用户他们最喜欢的RPG.然后它显示默认值.我知道这是一个小例子,但我的程序不会运行,因为我收到此错误:

The type or namespace name 'Interaction' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

最初我在这里发现了这个

c# inputbox

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