小编Les*_*ers的帖子

在foreach循环中删除列表中的项目c#

如果我在 foreach 循环中使用一个项目并且我不能使用该项目,它必须删除当前在 foreach 循环中的项目。

这是我现在拥有的代码:

foreach (Line line in linelijst)
{
    try
    {
        if (line.ActorIndex() == 0)
        {
            line.setStartPoint(actorenlijst[0].getLinePoint()); //if actorenlijst[0] doesn't excist it has to delete the current line
        }
        if (line.ActorIndex() == 1)
        {
             line.setStartPoint(actorenlijst[1].getLinePoint()); //if actorenlijst[1] doesn't excist it has to delete the current line
        }
        if (line.ActorIndex() == 2)
        {
             line.setStartPoint(actorenlijst[2].getLinePoint()); //if actorenlijst[2] doesn't excist it has to delete the current line
        }
        Point start = line.getStartPoint();
        Point end = line.getEndPoint();
        Pen lijn = new …
Run Code Online (Sandbox Code Playgroud)

c# foreach

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

从 Twitter OAuth2 获取电子邮件

我正在 Laravel 中使用 Socialite 来登录 Twitter。

我知道并非所有 Twitter 用户的帐户都附有电子邮件,但对于我的应用程序,用户确实需要电子邮件地址。我可以阻止没有附加电子邮件的人登录,但目前每个用户都将电子邮件字段设置为空。

我正在使用这个函数重定向到 Twitter:

return Socialite::driver($provider)->redirect();
Run Code Online (Sandbox Code Playgroud)

我已经尝试过使用这样的范围:

return Socialite::driver($provider)->scopes(['email'])->redirect();
Run Code Online (Sandbox Code Playgroud)

但 Twitter 是唯一不允许范围的提供商。

回调返回 Facebook 和 google 等其他提供商的电子邮件地址,但在使用 Twitter 时似乎缺少一些东西。

对于 OAuth1,有一个设置可以启用返回电子邮件字段的选项,但由于 twitter 接受 OAuth2,我在 Twitter 开发人员面板中再也找不到此设置。

由于有关此主题的大多数信息都已过时,因此我将不胜感激。

twitter oauth-2.0 twitter-oauth laravel laravel-socialite

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

asp.net奇怪的错误创建一个DateTime

我想用我在asp.net中编写的下一个代码创建一个帐户

但每当我创建日期时间时,它都会把我扔进catch块,现在我使用了简单的值,如:

DateTime birthdate = new DateTime(1, 2, 2003);
Run Code Online (Sandbox Code Playgroud)

但是当我检查调试器时,它让我脱离了这一行的try块,我真的不明白为什么因为Visual Studio没有给我任何错误所以这里可能出错???

try
{
    // male/female check
    string sex = "";
    if (rbMale.Checked)
    {
        sex = "Male";
    }
    else if (rbFemale.Checked)
    {
        sex = "Female";
    }
    // birthday
    int bdday = Convert.ToInt32(tbBdayDay.Value.ToString());
    int bdmonth = Convert.ToInt32(cbBdayMonth.Value.ToString());
    int bdyear = Convert.ToInt32(tbBdayYear.Value.ToString());

    //this line is pushing me into the catch block!! :(
    DateTime birthdate = new DateTime(1, 2, 2003);
    // username
    string name = tbFirstName.Value.ToString() + " " + tbLastName.Value.ToString();
    // fileshare link: …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net

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