我需要无限符号 TextBlock
如果我写"∞"的TextBlock.Text都是好的,用TextBlock"∞"符号.
<TextBlock Text="∞"/>
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用Converter.
<TextBlock Text="{Binding MyValue, Converter={StaticResource MyConverter}}"/>
Run Code Online (Sandbox Code Playgroud)
我有"∞"文字TextBlock.
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return "∞";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
有什么解决方案吗?
我有一些类和接口
public interface IGeoObject
{
GeoCoordinate GetGeocoordinate();
}
public class User : IGeoObject
{
public GeoCoordinate GetGeocoordinate()
{
//...
return GeoCoordinate;
}
}
public class Venue : IGeoObject
{
public GeoCoordinate GetGeocoordinate()
{
//...
return GeoCoordinate;
}
}
public class Place : IGeoObject
{
public GeoCoordinate GetGeocoordinate()
{
//...
return GeoCoordinate;
}
}
Run Code Online (Sandbox Code Playgroud)
我有,类型的示例变量用户 List<User>
我有签名的方法
double GetMinDistance(List<IGeoObject> objects, GeoCoordinate position)
Run Code Online (Sandbox Code Playgroud)
我无法传递用户GetMinDistance,因为泛型类型的协方差不起作用.
我可以创建额外的列表和使用方法.ConvertAll(或.CasT<T>):
List<IGeoObject> list = new List<User>(listUser).ConvertAll(x => (IGeoObject)x);
var dist = GeoTest.GetMinDistance(list, …Run Code Online (Sandbox Code Playgroud) 我在Windows Phone 8应用程序中有一个本地数据库.该应用程序包含对数据库的大量查询,我不希望对UI的响应性产生不良影响.
例如,我有一个用户表和方法,用于通过id从数据库中获取用户.
目前的变种
public class CacheDataContext : DataContext
{
public static string DBConnectionString = "Data Source=isostore:/Cache.sdf";
public CacheDataContext(string connectionString)
: base(connectionString) { }
public static AutoResetEvent OperationOnDatabaseUser = new AutoResetEvent(true);
public Table<User> UserItems;
}
public class CacheDataContextUser : CacheDataContext
{
public CacheDataContextUser(string connectionString)
: base(connectionString) { }
public User GetUser(string id)
{
try
{
OperationOnDatabaseUser.WaitOne();
using (CacheDataContext context = new CacheDataContext(DBConnectionString))
{
//find user in the data base and return
}
}
finally
{
OperationOnDatabaseUser.Set();
} …Run Code Online (Sandbox Code Playgroud) c# thread-safety windows-phone-7 async-await windows-phone-8
帮我解析json用Newtonsoft.Json。
{
"_id": 160,
"location": {
"type": "Point",
"coordinates": [43.59043144045182, 39.72119003534317]
},
},
{
"_id": 161,
"location": {
"type": "LineString",
"coordinates": [
[43.58780105200211, 39.719191789627075],
[43.58817794899264, 39.719465374946594]
]
},
},
{
"_id": 152,
"location": {
"type": "Polygon",
"coordinates": [
[43.590524759627954, 39.71930980682373],
[43.590474249766544, 39.71926689147949],
[43.59043151061995, 39.71934735774994],
[43.59073456936772, 39.71958339214325],
[43.59076565222992, 39.71949219703674]
]
},
}
Run Code Online (Sandbox Code Playgroud)
键coordinates具有类型List<double>或List<List<double>>取决于键type(多边形,线串,点)。
我在 Java 中需要这样的东西(C# 示例)
class Program
{
static void Main(string[] args)
{
Method<String>();
}
static void Method<T>()
{
Type typeT = typeof(T);
Type typeString = typeof(String);
if (typeT == typeString)
{
Console.WriteLine("Is String");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有通用方法,需要在方法中检查类型 T。
protected <T> MyClass<T> myMethod(MyClass<T> myObj){
// if T is string do ..., else do ...
}
Run Code Online (Sandbox Code Playgroud)