private void button3_Click(object sender, EventArgs e) { string s = textBox2.Text; ContractParameter parameter = new ContractParameter(); if (string.Equals(s, "true", StringComparison.OrdinalIgnoreCase)) { parameter.Type = ContractParameterType.Boolean; parameter.Value = true; } else if (string.Equals(s, "false", StringComparison.OrdinalIgnoreCase)) { parameter.Type = ContractParameterType.Boolean; parameter.Value = false; } else if (long.TryParse(s, out long num)) { parameter.Type = ContractParameterType.Integer; parameter.Value = num; } else if (s.StartsWith("0x")) { if (UInt160.TryParse(s, out UInt160 i160)) { parameter.Type = ContractParameterType.Hash160; parameter.Value = i160; } else if (UInt256.TryParse(s, out UInt256 i256)) { parameter.Type = ContractParameterType.Hash256; parameter.Value = i256; } else if (BigInteger.TryParse(s.Substring(2), NumberStyles.AllowHexSpecifier, null, out BigInteger bi)) { parameter.Type = ContractParameterType.Integer; parameter.Value = bi; } else { parameter.Type = ContractParameterType.String; parameter.Value = s; } } else if (ECPoint.TryParse(s, ECCurve.Secp256r1, out ECPoint point)) { parameter.Type = ContractParameterType.PublicKey; parameter.Value = point; } else { try { parameter.Value = s.HexToBytes(); parameter.Type = ContractParameterType.ByteArray; } catch (FormatException) { parameter.Type = ContractParameterType.String; parameter.Value = s; } } parameters.Add(parameter); listView1.Items.Add(new ListViewItem(new[] { new ListViewItem.ListViewSubItem { Name = "index", Text = $"[{listView1.Items.Count}]" }, new ListViewItem.ListViewSubItem { Name = "type", Text = parameter.Type.ToString() }, new ListViewItem.ListViewSubItem { Name = "value", Text = parameter.ToString() } }, -1) { Tag = parameter }); }