我正在尝试使用Lextm.SharpSnmpLib.Messaging从Snmp设备获取OID值(字符串格式)。对于正常的OID值,它可以正确显示,但是在转换Mac地址包含('-')时,它不能正确转换,并显示“ \ u0000 k ???”。任何转换建议,下面是附带的代码。
IList<Variable> result = Messenger.Get(VersionCode.V1,
new IPEndPoint(IPAddress.Parse(sIpAddress),
objSNMPv1Setting.Port),
new OctetString(objSNMPv1Setting.CommunityName),
lstOid.Select(x => new Variable(new ObjectIdentifier(x))).ToList(),
objSNMPv1Setting.Timeout);
foreach (var o in result)
{
dictResponce.Add(o.Id.ToString(), o.Data.ToString());
}
OID值:ABC
o.Data.ToString() = ABC
OID值:00-20-6B-93-EC-81
o.Data.ToString() = \u0000 k???
预期
OID值:00-20-6B-93-EC-81
o.Data.ToString() = 00-20-6B-93-EC-81