本文整理汇总了C#中System.UInt16.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UInt16.ToString方法的具体用法?C# UInt16.ToString怎么用?C# UInt16.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UInt16
的用法示例。
在下文中一共展示了UInt16.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadRom
static void LoadRom(string fileName, UInt16 memoryAddress)
{
BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open));
int pos = 0;
UInt16 index = memoryAddress;
int length = (int)reader.BaseStream.Length;
try
{
while (pos < length)
{
byte[] word = reader.ReadBytes(2);
if (BitConverter.IsLittleEndian)
Array.Reverse(word);
UInt16 data = BitConverter.ToUInt16(word, 0);
//UInt16 data = reader.ReadUInt16();
Console.Write(data.ToString("X") + ":");
MasterComponent.Instance.MemoryMap.Write16BitsToAddress(index, data);
pos += sizeof(UInt16);
index += 1;
}
Console.WriteLine("Loaded rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
}
catch (Exception ex)
{
Console.WriteLine("Error loading rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
Console.WriteLine(ex);
}
reader.Close();
}
示例2: TelemetryPacket
public TelemetryPacket(String telemetry)
{
isPayload = checkIfFromPayload(telemetry); // This should be done first before conversions
temperature = getShortInt(telemetry.Substring(TEMPERATURE_IDX, 4)) * 0.1; // unvonverted temp is in 0.1 celsious
altitude = getShortInt(telemetry.Substring(ALT_IDX, 4))*0.1; // Altitude expected is in 100m's
missionTime = getUShortInt(telemetry.Substring(MISSION_TIME_IDx, 4));
packetCount = getUShortInt(telemetry.Substring(PACKET_COUNT_IDX, 4));
batVoltage = getShortInt(telemetry.Substring(SOURCE_VOLT_IDX,4));
lux = getUnsignedShortInt(telemetry.Substring(LUM_IDX,4))*16;
payloadDeployed = telemetry.Substring(PAYLOAD_DEPLOYED_IDX, 1) == "F";
umbrellaDeployed = telemetry.Substring(UMBRELLA_DEPLOYED_IDX, 1) == "F";
packetArray = new String[] {
TEAM_ID,
packetCount.ToString(),
missionTime.ToString(),
altitude.ToString("F1"),
temperature.ToString("F1"),
batVoltage.ToString("F1"),
lux.ToString()
};
packetString = String.Join(",",packetArray);
}
示例3: GetFormatName
public static String GetFormatName(UInt16 format)
{
// registered Clipboard formats
var name = GetRegisteredFormatName(format);
if (name != null)
{
return name;
}
// standard Clipboard formats
var standardFormats = Enum.GetValues(typeof(ClipboardFormats));
foreach (var standardFormat in standardFormats)
{
if ((UInt16)standardFormat == format)
{
return standardFormat.ToString();
}
}
// private Clipboard formats
if ((format > Win32Api.CF_PRIVATEFIRST) && (format < Win32Api.CF_PRIVATELAST))
{
return String.Format("CF_PRIVATEFIRST + {0}", format - Win32Api.CF_PRIVATEFIRST);
}
else if ((format > Win32Api.CF_GDIOBJFIRST) && (format < Win32Api.CF_GDIOBJLAST))
{
return String.Format("CF_GDIOBJFIRST + {0}", format - Win32Api.CF_PRIVATEFIRST);
}
return format.ToString();
}
示例4: DoPosTest
public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI)
{
bool retVal = true;
string errorDesc;
string actualValue;
TestLibrary.TestFramework.BeginScenario(testDesc);
try
{
actualValue = uintA.ToString(format, _NFI);
if (actualValue != expectedValue)
{
errorDesc =
string.Format("The string representation of {0} is not the value {1} as expected: actual({2})",
uintA, expectedValue, actualValue);
errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed";
TestLibrary.TestFramework.LogError(id + "_001", errorDesc);
retVal = false;
}
}
catch (Exception e)
{
errorDesc = "Unexpect exception:" + e;
errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed.";
TestLibrary.TestFramework.LogError(id + "_002", errorDesc);
retVal = false;
}
return retVal;
}
示例5: Read16BitsFromAddress
public UInt16 Read16BitsFromAddress(UInt16 address)
{
UInt16 returnValue = 0;
if (address >= 0 && address <= 0x7F) // note for some reason the STIC only actually uses the range from 0 to 0x3F
returnValue = MasterComponent.Instance.STIC.Read(address); // STIC REGISTERS
else if (address >= 0x0100 && address <= 0x01EF)
returnValue = _scratchpadRAM.Read(address - 0x0100);
else if (address >= 0x01F0 && address <= 0x01FF)
returnValue = MasterComponent.Instance.PSG.Read(address - 0x01F0); // not totally sure this needs to be subtracting
else if (address >= 0x0200 && address <= 0x035F)
returnValue = _systemRAM.Read(address - 0x0200);
else if (address >= 0x1000 && address <= 0x1FFF)
returnValue = _executiveROM.Read(address - 0x1000);
else if (address >= 0x3000 && address <= 0x37FF)
returnValue = _graphicsROM.Read(address - 0x3000);
else if (address >= 0x3800 && address <= 0x39FF)
returnValue = _graphicsRAM.Read(address - 0x3800);
else
returnValue = _cartridge.Read(address - 0x3A00);
Console.WriteLine(" RD a=0x" + address.ToString("X") + " v=0x" + returnValue.ToString("X") + ", " + Convert.ToString(returnValue, 2).PadLeft(8, '0'));
return returnValue;
}
示例6: addAbility
public void addAbility(Int32 abilityID, UInt16 slotID, UInt32 charID, UInt16 level, UInt16 is_loaded)
{
string theQuery = "INSERT INTO char_abilities SET char_id='" + charID.ToString() + "', slot='" + slotID.ToString() + "', ability_id='" + abilityID.ToString() + "', level='" + level.ToString() + "', is_loaded='" + is_loaded.ToString() + "', added=NOW() ";
conn.Open();
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = theQuery;
queryExecuter.ExecuteNonQuery();
conn.Close();
}
示例7: addItemToInventory
public void addItemToInventory(UInt16 slotId, UInt32 itemGoID)
{
UInt32 charID = Store.currentClient.playerData.getCharID();
string sqlQuery = "INSERT INTO inventory SET charId = '" + charID.ToString() + "' , goid = '" + itemGoID.ToString() + "', slot = '" + slotId.ToString() + "', created = NOW() ";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = sqlQuery;
queryExecuter.ExecuteNonQuery();
}
示例8: ChangeMapProperties
private void ChangeMapProperties()
{
MapPropertiesDialog mapDialog = new MapPropertiesDialog();
mapDialog.MapName = mapName;
mapDialog.BitmapPath = bitmapPath;
mapDialog.TileWidth = tileWidth;
mapDialog.TileHeight = tileHeight;
mapDialog.MapWidth = mapWidth;
mapDialog.MapHeight = mapHeight;
if (mapDialog.ShowDialog() == DialogResult.OK)
{
tileWidth = mapDialog.TileWidth;
tileHeight = mapDialog.TileHeight;
mapWidth = mapDialog.MapWidth;
mapHeight = mapDialog.MapHeight;
twLabel.Text = tileWidth.ToString() + " px";
thLabel.Text = tileHeight.ToString() + " px";
mwLabel.Text = mapWidth.ToString() + " x " + tileWidth.ToString() + " px";
mhLabel.Text = mapHeight.ToString() + " x " + tileHeight.ToString() + " px";
tileContainer.ResetParameters();
map.ResetParameters();
tileContainer.SetParameters(tileBitmap, tileWidth, tileHeight);
try
{
map.SetParameters(tileWidth, tileHeight, mapWidth, mapHeight, mapDialog.BaseTiles, tileBitmap, tileContainer, mapObjects, objectContainer);
}
catch (Exception)
{
MessageBox.Show(Utils.ERROR_CREATING_MAP, Utils.APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
CloseMap();
return;
}
}
mapDialog = null;
}
示例9: getParam
public static string getParam(byte tp,UInt16 vl,OProg prog)
{
if (tp == ARG_STR)
{
foreach (OProg.OString s in prog.strings)
if (s.ofs == vl)
return "s" + s.id.ToString();
throw new Exception("String Not Found "+vl.ToString("X4"));
}
string res = "";
switch (tp)
{
case ARG_IMM: res = "i"; break;
case ARG_WORD: res = "w"; break;
case ARG_BYTE: res = "b"; break;
case ARG_CODE: res = "c"; break;
default:
throw new Exception("Anknown arg type " + tp.ToString());
}
res += vl.ToString("X4");
return res;
}
示例10: Ingredient_Instant
public Ingredient_Instant(UInt16 Id, UInt16 stm, EvoRecipe rcp,ObservableCollection<CanisterUnit> a)
{
_RecipeInfo = rcp;
_StartTime = stm;
_ID = Id;
_CanisterUnit = a;
_IngredientInfo = new IngredientInfo(IngredientType.INSTANTPOWDER);
SetIngredientInfo(_IngredientInfo, (IngredientInfo)_RecipeInfo._lstIngredientInfo.First(c => c.ID == _ID));
InitializeComponent();
this.DataContext = _IngredientInfo;
tbstm.Text = stm.ToString();
fillpowder();
ReloadCanisterIngredient();
}
示例11: Ingredient_FilterBrew
public Ingredient_FilterBrew(UInt16 Id,UInt16 stm,EvoRecipe rcp)
{
// _EvoRecipe = (EvoRecipe)Function.XmlSerializer.LoadFromXml("EVO.Ingredient.xml", typeof(EvoRecipe));
_RecipeInfo = rcp;
_StartTime = stm;
_ID = Id;
_IngredientInfo = new IngredientInfo(IngredientType.FILTERBREW);
SetIngredientInfo(_IngredientInfo, (IngredientInfo)_RecipeInfo._lstIngredientInfo.First(c => c.ID == _ID));
InitializeComponent();
this.DataContext = _IngredientInfo;
tbstm.Text = stm.ToString();
tbpkg1.Text = Function.GetBeanType(_IngredientInfo._FilterBrew.Grind1Type);
tbpkg2.Text = Function.GetBeanType(_IngredientInfo._FilterBrew.Grind2Type);
}
示例12: btnFindDevice_Click
private void btnFindDevice_Click(object sender, EventArgs e)
{
try
{
done = false;
Bootloader.Connect();
PageSize = Bootloader.PageSize;
FlashSize = Bootloader.FlashSize;
Logger.Write("Connected");
#if DEBUG
Logger.Write("Page Size: " + PageSize.ToString() + " bytes");
Logger.Write("Flash Size: " + FlashSize.ToString() + " bytes");
#endif
this.btnLocateFirmware.Enabled = true;
this.btnFindDevice.Enabled = false;
}
catch (DeviceNotFoundException)
{
try
{
Device dev = new Device();
dev.Connect();
Logger.Write("Rebooting device into firmware update mode...");
dev.RebootToBootloader();
dev.Disconnect();
while (wait) /* Wait for device to reboot and be enumerated by the OS */
{
System.Threading.Thread.Sleep(200);
Application.DoEvents();
}
wait = true;
btnFindDevice_Click(null, null);
}
catch (DeviceNotFoundException)
{
done = true;
Logger.Write("Device not found!");
}
catch (NullReferenceException)
{
done = true;
Logger.Write("Device not found!");
}
}
}
示例13: Write16BitsToAddress
public void Write16BitsToAddress(UInt16 address, UInt16 value)
{
Console.WriteLine(" WR a=0x" + address.ToString("X") + " v=0x" + value.ToString("X"));
if (address >= 0 && address <= 0x7F) // note for some reason the STIC only actually uses the range from 0 to 0x3F
MasterComponent.Instance.STIC.Write(address, value); // STIC REGISTERS
else if (address >= 0x0100 && address <= 0x01EF)
_scratchpadRAM.Write(address - 0x100, value);
else if (address >= 0x01F0 && address <= 0x01FF)
MasterComponent.Instance.PSG.Write(address - 0x01F0, value); // not totally sure this needs to be subtracting
else if (address >= 0x0200 && address <= 0x035F)
_systemRAM.Write(address - 0x0200, value);
else if (address >= 0x1000 && address <= 0x1FFF)
_executiveROM.Write(address - 0x1000, value);
else if (address >= 0x3000 && address <= 0x37FF)
_graphicsROM.Write(address - 0x3000, value);
else if (address >= 0x3800 && address <= 0x39FF)
_graphicsRAM.Write(address - 0x3800, value);
else
_cartridge.Write(address - 0x3A00, value);
}
示例14: ToString
public static string ToString(UInt16 value)
{
return value.ToString(CultureInfo.InvariantCulture);
}
示例15: updateSourceHlForObjectTracking
public void updateSourceHlForObjectTracking(UInt16 sourceDistrict, UInt16 sourceHl, UInt32 lastObjectId)
{
string sqlQuery = "SELECT id,HardlineId, DistrictId, objectId FROM data_hardlines WHERE DistrictId = '" + sourceDistrict.ToString() + "' AND HardlineId = '" + sourceHl.ToString() + "' LIMIT 1";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = sqlQuery;
dr = queryExecuter.ExecuteReader();
UInt16 theId = 0;
UInt16 hardlineId = 0;
UInt16 districtId = 0;
UInt32 objectId = 0;
while (dr.Read())
{
theId = (UInt16)dr.GetInt16(0);
hardlineId = (UInt16)dr.GetInt16(1);
districtId = (UInt16)dr.GetInt16(2);
objectId = (UInt32)dr.GetInt32(3);
}
dr.Close();
if (objectId == 0 || objectId != lastObjectId)
{
string updateQuery = "UPDATE data_hardlines SET objectId = '" + lastObjectId.ToString() + "' WHERE id = '" + theId.ToString() + "' LIMIT 1";
queryExecuter = conn.CreateCommand();
queryExecuter.CommandText = updateQuery;
queryExecuter.ExecuteNonQuery();
Output.WriteLine("[WORLD DB] UPDATE Hardline " + hardlineId.ToString() + " in District " + districtId.ToString() + " with Object ID : "+lastObjectId.ToString());
}
}