在C#(.NET)中,常规的"格式化"标准是什么?
例如,对于参数名称,到目前为止我注意到没有前缀的camelCase,是吗?对于对象名称,camelCase也没有前缀,对吧?
对于名称空间,类,函数和属性,单词的首字母大写且没有前缀,这是否正确(再次)?
"临时"对象是如何格式化的?
例:
namespace TestNamespace
{
class MyOwnCoolClass
{
MyOwnCoolClass(int length, BinaryWriter writer)
{
BinaryWriter tempbw = new BinaryWriter(length);
return tempbw;
}
}
}
Run Code Online (Sandbox Code Playgroud)
(注意:此代码无效,我知道,这只是为了演示格式化).谢谢!
假设函数foo()正在执行.假设发生了一个外部事件,你有一个处理程序.函数foo()会被中断,以便可以执行事件处理程序吗?在这种情况下执行的顺序是什么?
我有一个用折线对象动态制作的图形。它产生了一些有趣的东西,但我只想保留最后 10 个坐标,一旦我们到达第 10 个位置,每个坐标都会向左移动 X 像素,新值将在最后添加。
在我的绘图类的 Add 函数中,我尝试了这种代码:
if (points.Count > 10)
{
myPolyline.Points.RemoveAt(0);
foreach(Point p in myPolyline.Points)
{
p.X = p.X - 50;//Move all coord back to have a place for the new one
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为我们无法在 ForEach 循环中修改集合的变量。在 WPF/C# 中执行此操作的最佳方法是什么?
我可以这样做:
for (int i = 0; i < this.myPolyline.Points.Count; i++)
{
this.myPolyline.Points[i] = new Point(this.myPolyline.Points[i].X - 50, this.myPolyline.Points[i].Y);
}
Run Code Online (Sandbox Code Playgroud)
但我想要一种更简洁的方法来做到这一点,而不必非常时间创建点对象。
我有一个winxp进程,它有各种dll和静态库.我们的一个库是调用ms调试dll,我怀疑它是哪一个但是想在Process Explorer这样的工具中证明它.如何获得我的流程树,以确切了解谁正在加载哪些模块?
可能重复:
Mono准备好黄金时间吗?
我有几个与彼此有关的问题.
我该如何解决这个错误?
foreach (values %{$args{car_models}}) {
push(@not_sorted_models, UnixDate($_->{'year'},"%o"));
}
Run Code Online (Sandbox Code Playgroud)
错误:在/.../BMW.pm第222行使用"严格参考"时,不能使用字符串("1249998666")作为HASH参考.
我正在尝试使用Rails创建一个注册表单.它工作正常,但它不会显示验证中的错误(它会验证,但错误不会显示).
这是我的文件:
# new.html.erb
<h1>New user</h1>
<% form_for :user, :url =>{:action=>"new", :controller=>"users"} do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :password %><br />
<%= f.password_field :password %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', users_path %>
Run Code Online (Sandbox Code Playgroud)
# user.rb
class User < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :password
end
Run Code Online (Sandbox Code Playgroud)
#users_controller.rb
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = …Run Code Online (Sandbox Code Playgroud) 在我看来,内置函数__repr__和__str__它们的基本定义有重要区别.
>>> t2 = u'\u0131\u015f\u0131k'
>>> print t2
???k
>>> t2
Out[0]: u'\u0131\u015f\u0131k'
Run Code Online (Sandbox Code Playgroud)
t2.decode因为t2是unicode字符串而引发错误.
>>> enc = 'utf-8'
>>> t2.decode(enc)
------------------------------------------------------------
Traceback (most recent call last):
File "<ipython console>", line 1, in <module>
File "C:\java\python\Python25\Lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordin
al not in range(128)
Run Code Online (Sandbox Code Playgroud)
__str__引发错误,就像decode()调用函数一样:
>>> t2.__str__()
------------------------------------------------------------
Traceback (most recent call last):
File "<ipython console>", line …Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
sql ×2
actionscript ×1
apache-flex ×1
c++ ×1
django ×1
dll ×1
flash ×1
flex3 ×1
formatting ×1
forms ×1
mono ×1
performance ×1
perl ×1
polyline ×1
process ×1
python ×1
ruby ×1
sql-server ×1
standards ×1
string ×1
unicode ×1
winapi ×1
wpf ×1