error CS0029: 无法将类型“int”隐式转换为“Redmine.Net.Api.Types.IdentifiableName” 如何解决
时间: 2023-12-14 19:39:20 浏览: 253
这个错误是因为你尝试将一个int类型隐式转换为IdentifiableName类型,但编译器无法识别这种转换。你需要将int类型显式转换为IdentifiableName类型。
你可以尝试像这样进行显式转换:
```csharp
int myInt = 123;
IdentifiableName myIdentifiableName = new IdentifiableName((long)myInt);
```
或者你可以将int类型转换为字符串类型,然后将其传递给IdentifiableName构造函数:
```csharp
int myInt = 123;
IdentifiableName myIdentifiableName = new IdentifiableName(myInt.ToString());
```
希望这能帮助你解决问题。
相关问题
Redmine.Net.Api.Types.TimeEntry 如何获取一个Activity
要获取一个活动(Activity),可以使用 Redmine.Net.Api.Types.TimeEntry 的 Activity 属性。Activity 对象包含了活动的名称、ID、费率等信息。
以下是获取 TimeEntry 对象的 Activity 的示例代码:
```csharp
using Redmine.Net.Api;
using Redmine.Net.Api.Types;
var redmineManager = new RedmineManager(redmineUrl, apiKey);
var timeEntry = redmineManager.GetObject<TimeEntry>(timeEntryId.ToString(), new NameValueCollection { { "include", "activity" } });
var activity = timeEntry.Activity;
Console.WriteLine($"Activity name: {activity.Name}");
Console.WriteLine($"Activity ID: {activity.Id}");
```
在上面的代码中,我们使用 RedmineManager 的 GetObject 方法获取 TimeEntry 对象,并传递了一个 NameValueCollection 参数来指示我们需要包含 Activity 信息。然后,我们可以从 TimeEntry 对象的 Activity 属性中获取 Activity 对象,并访问其属性。
Redmine.Net.Api.Types.TimeEntry 如何和issue关联并给出示例代码
可以使用Redmine.Net.Api.Types.TimeEntry的IssueId属性将TimeEntry与Issue关联起来。以下是一个示例代码片段,演示如何创建一个与Issue关联的TimeEntry:
```csharp
using Redmine.Net.Api;
using Redmine.Net.Api.Types;
using System;
namespace RedmineTimeEntryExample
{
class Program
{
static void Main(string[] args)
{
var redmineManager = new RedmineManager("https://your.redmine.url", "your-api-key");
// create a new time entry
var timeEntry = new TimeEntry
{
ActivityId = 9, // set the activity ID
SpentOn = DateTime.Now.Date, // set the date
Hours = 2.5F, // set the time spent
Comments = "Some comments here", // set the comments
IssueId = 123 // set the issue ID
};
// create the time entry and associate it with the issue
var createdTimeEntry = redmineManager.CreateObject<TimeEntry>(timeEntry);
Console.WriteLine("Time entry created successfully!");
}
}
}
```
在上面的代码中,我们设置了TimeEntry的IssueId属性,将其与Issue关联起来。在创建TimeEntry时,Redmine.Net.Api会自动将其与相应的Issue关联起来。
阅读全文
相关推荐
















