本文整理汇总了C#中Microsoft.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Read方法的具体用法?C# Microsoft.Read怎么用?C# Microsoft.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTemperature
/// <summary>
/// Get temperature
/// </summary>
/// <param name="Celsius">Is degree Celcius</param>
/// <param name="tempSensor">Temperature sensor signal pin.</param>
/// <returns></returns>
public static string GetTemperature(bool Celsius, Microsoft.SPOT.Hardware.AnalogInput tempSensor)
{
//Microsoft.SPOT.Hardware.AnalogInput tempSensor = new Microsoft.SPOT.Hardware.AnalogInput(SecretLabs.NETMF.Hardware.NetduinoPlus.AnalogChannels.ANALOG_PIN_A5);
string temperature = string.Empty;
float volts = 0;
int i = 1;
#if MF_FRAMEWORK_VERSION_V4_1
int vInput = tempSensor.Read();
//float volts = ((float)vInput / 1024.0f) * 3.3f;
while(i<=SAMPLES)
{
volts += ((float)vInput / 1024.0f) * 3.3f;
i++;
)
#endif
#if MF_FRAMEWORK_VERSION_V4_2
double vInput = tempSensor.Read();
//volts = ((float)vInput / 1024.0f) * 3.3f *1000;
while (i <= SAMPLES)
{
//its actually millivolts
volts += ((float)vInput / 1024.0f) * 3300.0f;
i++;
}
#endif
volts = volts / SAMPLES;
float temp_C = (volts - 0.5f);
temp_C = temp_C * 100;
//float F = (1.8f) * (C + 32);
//F = (9/5*C) +32;
float temp_F = (1.8f * temp_C) + 32;
temperature = Celsius ? System.Math.Round(temp_C).ToString() + " ℃" : System.Math.Round(temp_F).ToString() + " ℉";
return temperature;
}
}
示例2: ReadPropertyBag
private static object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)
{
object val = null;
try
{
pb.Read(propName, out val, 0);
}
catch (ArgumentException)
{
return val;
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
return val;
}