每次打开串口时都会收到以下字符串,此字符串用于检查连接设备运行的BIOS版本和固件版本.
串:
v03400216000000001FC5H240108206B-RAMBOX=[03]
Run Code Online (Sandbox Code Playgroud)
现在,检查Bios版本和固件版本的唯一重要的字符如下:
03400216
Run Code Online (Sandbox Code Playgroud)
注意:bytearray是byte[]转换为a string并填充:
v03400216000000001FC5H240108206B-RAMBOX=[03]
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码实现此目的:
string versiontext = bytearray.Trim();
bytearray = versiontext.Remove(0, 2);
versiontext = bytearray.Remove(9, bytearray.Length);
bytearray = versiontext;
Run Code Online (Sandbox Code Playgroud)
但这没有成功,导致以下异常:
Index and count must refer to a location within the string.
Run Code Online (Sandbox Code Playgroud)
我应该使用a Regex而不是.Remove?
编辑:
@lazyberezovsky帮助我,我只是忘记了.Substring().
我string result用以下代码实现了:
if (bytearray.Contains("RAMBOX"))
{
string Versionstring = bytearray.Substring(1, 8);
bytearray = Versionstring;
}
Run Code Online (Sandbox Code Playgroud) 为什么我不能创建两个重载方法,其参数既是数组列表,又有不同的数据类型?
public class test {
public static void main(String[] args){
ArrayList<Integer> ints = new ArrayList<Integer>();
ints.add(1);
ints.add(2);
ints.add(3);
ints.add(4);
ints.add(5);
showFirst(ints);
ArrayList<Double> dubs = new ArrayList<Double>();
dubs.add(1.1);
dubs.add(2.2);
dubs.add(3.3);
dubs.add(4.4);
dubs.add(5.5);
showFirst(dubs);
}
public static void showFirst(ArrayList<Integer> a)
{
System.out.println(a.remove(0));
}
public static void showFirst(ArrayList<Double> a)
{
System.out.println(a.remove(0));
}
}
Run Code Online (Sandbox Code Playgroud)
我在eclipse中,它强调了导致代码为红色的问题并给出了这样的信息: Method showFirst(ArrayList<Integer>) has the same erasure showFirst(ArrayList<E>) as another method in type test
我能让它工作的唯一方法是添加其他参数,例如, int bafter showFirst(ArrayList<Integer> a和, int bafter showFirst(ArrayList<Double> a.
有没有办法让这段代码按照我的意图运作?如果没有,我想知道为什么会这样. …
我正在开发一款游戏,我正在为我的加载屏幕使用多个线程,以加载音乐和纹理.
我用这种方式启动线程:
backgroundgeluidThread = new Thread(loadmusic);
backgroundtexturesThread = new Thread(loadtextures);
backgroundgeluidThread.Start();
backgroundtexturesThread.Start();
Run Code Online (Sandbox Code Playgroud)
在那之后,我使用了一个Thread.Sleep(8000),因为我不知道线程何时停止并完成了他们的工作.我可以在IDE的输出中看到它,但我不知道我的线程何时完成.
在此先感谢,并问我是否不理解我的问题.
如何从中删除空字节List<byte>?
例如,我有一个大小为的列表[5].
[0] = 5
[1] = 3
[2] = 0
[3] = 0
[4] = 17
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我想删除byte索引:2和3.
列表中的项目每秒都会更改.所以下次列表可以填充类似的东西:
[0] = 0
[1] = 2
[2] = 3
[3] = 4
[4] = 0
Run Code Online (Sandbox Code Playgroud) 我正在尝试将以下文本添加到我的数据库: Zeeland '96
但单引号给了我错误.
它应该如下所示:
INSERT INTO Department (Code, Name, CountryID) VALUES ('ZE', 'Zeeland '96', 1)
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,此刻缺少一个引用,我怎么能摆脱这个问题呢?
提前致谢!
如何调用以下方法手册?
private void NetworkResponseReceived(object sender, Network.ResponseReceivedEventArgs e)
{
ExecuteTask();
}
Run Code Online (Sandbox Code Playgroud)
有类似的东西:
NetworkResponseReceived();
Run Code Online (Sandbox Code Playgroud)
什么需要插入括号内?
我有一个sqlite database带table Users看起来如下:
Username | InsertDateTime
User101 4/22/2013 11:44
User102 3/22/2013 12:43
User103 4/22/2013 15:20
User104 1/21/2012 16:31
Run Code Online (Sandbox Code Playgroud)
我想select在Username与highest datetime.在这种情况下,用户103.
我试过queries像:
Select Username from Users where InsertDateTime = MAX(datetime);
Run Code Online (Sandbox Code Playgroud)
但这不是有效的sqlite query.
有人可以帮帮我吗?提前致谢!
能否请您告诉我如何使用共享首选项在共享首选项文件中写入多个条目。就像我想在共享首选项文件中添加多个名称一样,我正在使用以下代码,但是每次单击提交按钮时,它都会覆盖上一个条目。
public void onClick(View v)
{
SharedPreferences settings = getSharedPreferences("users", 0);
SharedPreferences.Editor editorUser = settings.edit();
editorUser.putString("user", editUser.getText().toString());
editorUser.commit();
}
Run Code Online (Sandbox Code Playgroud) private Dictionary<string, Dictionary<string, string>> sort(Dictionary<string, Dictionary<string, string>> prods)
{
int a, b;
var sortedDict =new Dictionary<string, Dictionary<string, string>>();
sortedDict = from entry in prods orderby entry.Value["SortOrder"] ascending select entry;
return sortedDict;
}
Run Code Online (Sandbox Code Playgroud)
错误:
错误4无法将类型'System.Linq.IOrderedEnumerable >>'隐式转换为'System.Collections.Generic.Dictionary>'。存在显式转换(您是否缺少演员表?)
我是vb.net的新手,我正在开发一个web服务.我想在json对象中发送响应.我只有一个字符串作为回应.
public string GetUser(String IMEI)
{
string msg = "";
string SQL1 = "Select Email from [Customer] where [Vehicle]='" + IMEI + "'";
DataTable dt = dbcom.GetDataTable(SQL1);
if (dt.Rows.Count > 0)
{
msg = dt.Rows[0]["Email"].ToString();
//CV(username, IMEI);
//vehiclechk(IMEI);
}
return msg;
}
Run Code Online (Sandbox Code Playgroud)
这发送xml字符串.我们如何将msg字符串转换为json.