小编suj*_*lil的帖子

堆栈溢出异常,没有递归

我遇到堆栈溢出异常的问题,但我不知道是什么导致异常被抛出.我正在使用一个类库,其中包含我需要的所有方法和对象,并从控制台应用程序运行它.

任何帮助将不胜感激,因为这是一个任务的一部分,将在几个小时内到期.

这是我的代码:

TrafficIncidentNotificationRadiusCalculator类

namespace TrafficIncident
{
public class TrafficIncidentNotificationRadiusCalculator
{
    public double meters;
    public double CONFIGURED_NOTIFICATION_RADIUS
    {
        get { return CONFIGURED_NOTIFICATION_RADIUS; }
        set { CONFIGURED_NOTIFICATION_RADIUS = meters; }
    }

    public List<string> GetNotificationRecipientsList(List<User> users, List<UserLocationUpdate> userLocation, TrafficIncidentReport report)
    {
        int i = 0;
        List<string> userNotificationIds = new List<string>();
        while (i < userLocation.Count)
        {
            UserLocationUpdate userLoc = userLocation.ElementAt(i);
            userNotificationIds.Add(userLoc.userNotificationId);
            Console.WriteLine(userNotificationIds.ElementAt(i));
            i++;
        } 
        return userNotificationIds;
    }
}
}
Run Code Online (Sandbox Code Playgroud)

TrafficIncidentReport类

namespace TrafficIncident
{
public class TrafficIncidentReport
{
    public double[] incidentLocation;

    public double latitude …
Run Code Online (Sandbox Code Playgroud)

c# stack-overflow class-library console-application

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

如何将布尔值转换为字符串

我只是希望获得一个复选框和未选中的值作为"-1""0".我这样想:

Conversions.ToString((-((CheckBox1.Checked) ? 1 : 0)) ? 1 : 0)
Run Code Online (Sandbox Code Playgroud)

但得到以下错误

无法将类型'int'隐式转换为'bool'

我怎么能用类似的表达方式呢?

c#

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

由于此错误,我的代码行无法工作?

所以基本上这是问题所在,我尝试了许多方法来解决它,但没有一个起作用!错误出现在这条线上:Templist.Add((string)result["titre"];Templist是错误!

private List<string> ReadNews()
{
    string SqlText = "SELECT * FROM nom_table"; 
    List<string> Templist; 
    MySqlConnection SqlConnection = new 
    MySqlConnection(TheConnectionString);
    MySqlCommand SqlCommand = new 
    MySqlCommand(SqlText,SqlConnection);


    MySqlDataReader result = SqlCommand.ExecuteReader();

    while (result.Read())
    {
        Templist.Add((string)result["titre"]);
    }

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

c# winforms

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

重新分配对象时会发生什么?

使用以下实例化对象时:

Foo objFoo = new Foo();
Run Code Online (Sandbox Code Playgroud)

objFoo重新分配它的引用时,它的内存分配会发生什么?

objFoo = new Foo();
Run Code Online (Sandbox Code Playgroud)

分配给null时怎么办?

objFoo = null
Run Code Online (Sandbox Code Playgroud)

.net c# memory class object

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

将月份与linq进行比较

我想比较linq中两个值的月份部分,但我得到一个错误

属性或索引器DateTime.Month无法分配给

这是代码

var item = model.Where(d => d.DATE2.Date.Month = dto.StartDate.Month).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

model 是具有日期时间属性的对象列表,dto.Startdate也是日期时间

c# linq datetime

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