本文介绍了java哈希表到c#字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java代码:
//BleDevice is a class
public Hashtable<String, BleDevice> meusBLEs = new Hashtable<String, BleDevice>();
//BleRequest is another class
BleRequest currentRequest = null;
//deviceAddress is a string from BleRequest
BleDevice ble=meusBLEs.get(currentRequest.deviceAddress);
我正在使用散列表,并将值设置为BleDevice变量;
I'm using a hashtable and set the value to the BleDevice variable;
现在我在c#中尝试做的是相同的事情,但使用字典:
Now what I'm trying to do in c#, is the same thing but using Dictionary:
public Dictionary<String, BleDevice> meusBLEs = new Dictionary<String, BleDevice>();
BleRequest currentRequest = null;
BleDevice ble = meusBLEs.get...//HERE'S IS WHAT I DON`T KNOW HOW TO DO. THE METHOD GET DON`T EXIST
我无法在c#中使用散列表,因为我无法设置参数如java的哈希表。
I can't use hashtable in c# cause I can't set the parameter like java's hashtable.
推荐答案
BleDevice ble = meusBLEs[currentRequest.deviceAddress];
这篇关于java哈希表到c#字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!