我从一开始就有这个问题,这是华氏和摄氏之间的转换.
private void button1_Click(object sender, EventArgs e)
{
float fahr, cel;
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text);
cel = (5/9)*(fahr-32);
richTextBox1.Text = "The Degree in Celsius is:" + cel.ToString() + Environment.NewLine + "cool isn't it!?";
}
else if (Fahrenheit.Checked == true )
{
cel = float.Parse(textBox1.Text);
fahr = ((9 * cel)/5)+ 32;
richTextBox1.Text = "The degree in Fahrenheit is:" + fahr.ToString() + Environment.NewLine + "cool is it!?";
}
Run Code Online (Sandbox Code Playgroud)
当我想从华氏温度得到摄氏温度时它会一直给我0,即使这个公式似乎对我来说也是如此.这有什么不对?
因为我认为问题出在这里:
if (Celsius.Checked == true)
{
fahr = float.Parse(textBox1.Text); …Run Code Online (Sandbox Code Playgroud) 我试图在Linux(Ubuntu)中用C编译一组源文件.当我尝试运行以下命令时,我收到一个错误,告诉"ruby.h"找不到.
gcc custom_ext.c
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误消息.
custom_ext.h:10: fatal error: ruby.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
所以我下载了整个Ruby源代码并将其放在虚拟目录中/home/braga/ruby_source/ruby_1_8_7.我知道我需要在路径中包含这个目录,以便GCC能够识别并获取ruby.h,但我不知道如何做到这一点.请帮忙!!!
我必须拆分一个字符串,我想避免在括号内用逗号分隔它.那么我该如何实现呢?
例:
$string = "string1 (sString1, sString2,(ssString1, ssString2)), string2, string3";
result should be:
array(
[0] => string1 (sString1, sString2,(ssString1, ssString2))
[1] => string2
[2] => string3
)
Run Code Online (Sandbox Code Playgroud) 除了可用性:在JavaScript中从IE6 创建select具有5'000个option元素的标记的最快方法是什么?
$ie.Navigate("URL")和之间有什么区别$ie.Navigate2("URL")?
Get-Member说:
Navigate Method void Navigate (string, Variant, Variant, Variant, Variant)
Navigate2 Method void Navigate2 (Variant, Variant, Variant, Variant, Variant)
Run Code Online (Sandbox Code Playgroud)
示例代码:
$ie = New-Object -ComObject InternetExplorer.Application
$ie.visible = $true
$ie.Navigate("www.stackoverflow.com")
#or
$ie.Navigate2("www.stackoverflow.com")
Run Code Online (Sandbox Code Playgroud) 我正在学习MVVM,我想在ASP.NET中使用它.
我在互联网上找到的一些例子使用XAML作为视图.
有没有办法为视图使用常规ASP.NET页面而不是XAML?
这是一个XAML示例:
<UserControl x:Class="MVVMExample.DetailView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White"
DataContext="{Binding CurrentContact}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Name:" HorizontalAlignment="Right" Margin="5"/>
<TextBlock Text="{Binding FullName}"
HorizontalAlignment="Left" Margin="5" Grid.Column="1"/>
<TextBlock Text="Phone:" HorizontalAlignment="Right"
Margin="5" Grid.Row="1"/>
<TextBlock Text="{Binding PhoneNumber}"
HorizontalAlignment="Left" Margin="5"
Grid.Row="1" Grid.Column="1"/>
</Grid> </UserControl>
Run Code Online (Sandbox Code Playgroud)
感谢您的时间.
可能有人告诉我是否可以从一个@synchronized街区内返回?
例如:
- (id)methodThatReturnsSomething:(BOOL)bDoIt
{
@synchronized(self) {
if(!bDoIt) return nil;
...
}
}
Run Code Online (Sandbox Code Playgroud)
或者我应该先解锁块(使用NSLock代替)?
我正在使用cassandra,我想获取介于给定时间戳范围之间的记录.对此有什么疑问?我正在使用节俭客户端.
我试过这段代码.
String columnFamily = "UserColumnFamily";
String keyspace="Enterprise";
final String UTF8 = "UTF8";
String keyUserid="1";
TTransport tr = new TSocket("10.10.10.104", 9160);
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
SlicePredicate predicate = new SlicePredicate();
SliceRange sliceRange = new SliceRange();
String startkey="1293443184521000";
String finishkey ="1293445102333000";
sliceRange.setStart(new byte[0]);
sliceRange.setFinish(new byte[0]);
predicate.setSlice_range(sliceRange);
ColumnParent parent = new ColumnParent(columnFamily);
try {
tr.open();
List<KeySlice> results=client.get_range_slice(keyspace,parent,predicate,startkey,finishkey,100, ConsistencyLevel.ONE);
for (KeySlice result : results) {
Column column = (Column) result.columns;
System.out.println(new String(column.name,UTF8) + " ->> "
+ …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮我从bash脚本函数返回正确的值吗?
这是我的函数,它应该返回作为参数传递的文件的第一行(也是唯一的):
LOG_FILE_CREATION_TIME()
{
return_value=`awk 'NR==1' $1`
return return_value
}
Run Code Online (Sandbox Code Playgroud)
这是我在另一个脚本中对该函数的调用:
LOG_FILE_CREATION_TIME "logfile"
timestamp=$?
echo "Timestamp = $timestamp"
Run Code Online (Sandbox Code Playgroud)
我总是用这段代码得到一些随机值.例如,如果"logfile"中的值为62772031,我会得到
时间戳= 255
作为输出.对于文件中的其他一些值,我将其他随机值作为返回值,而不是正确的值.
有任何想法吗?
asp.net ×1
bash ×1
c ×1
c# ×1
cassandra ×1
com ×1
gcc ×1
javascript ×1
linux ×1
mdi ×1
mvvm ×1
object ×1
objective-c ×1
parentheses ×1
performance ×1
php ×1
powershell ×1
regex ×1
return-value ×1
ruby ×1
scripting ×1
select ×1
shell ×1
synchronized ×1
temperature ×1
wpf ×1