在我的WPF应用程序中,我在代码隐藏中的所有内容如下:
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
}
Run Code Online (Sandbox Code Playgroud)
我可以从项目中完全删除代码隐藏文件,还是必须留在那里?我的背景是在Web应用程序开发中,我将它与一个带有空的Page_Load()方法的代码隐藏文件联系起来,我通常会删除它.
public class emp
{
public int id { get; set; }
public string name { get; set; }
}
public class employee
{
public List<emp> Result { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想转换上面的课程
List<employee> e=new List<employee>();
Run Code Online (Sandbox Code Playgroud)
至
List<string> onj =new List<string>();
Run Code Online (Sandbox Code Playgroud)
谁能指导我?提前致谢.
我想在UserControl中执行以下操作:
foreach(Control c in this.Controls)
{
if(c is CheckBox)
{
// Do stuff here
}
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:
错误1找不到类型或命名空间名称'Control'(您是否缺少using指令或程序集引用?)
错误2找不到类型或命名空间名称'CheckBox'(您是否缺少using指令或装配参考?)
谢谢你的指导.
请原谅我的无知,有点像新手(但热情地到达那里)
public class MyType
{
public string MyName;
public string MyTown;
public string MyJob;
}
Run Code Online (Sandbox Code Playgroud)
我有这种类型的列表:
List<MyType> myVar = new List<MyType>()
Run Code Online (Sandbox Code Playgroud)
现在我想基于此返回一个布尔值.所以例如:myVar包含MyName = "Bob"和MyJob = "Taxi Driver"
我已经设法返回所有名称为"鲍勃"
var e = myVar.Where(x => x.MyName== "Bob").ToList();
Run Code Online (Sandbox Code Playgroud)
但我想做的事情如下:
bool mExists = (myVar.Where(x => x.MyName== "Bob" && MyJob="Taxi Driver").Count > 0) ? true : false;
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我必须使用文本框制作列表框......它必须是动态的.我在后面的代码中有可观察的集合,我想为listbox绑定它.我想要动态列表框,这个列表中应该有可编辑的文本框.所以,基本上我想从列表框中绑定multiplr文本框.任何帮助,将不胜感激
<ListBox HorizontalAlignment="Left" Name="ListTwo" Height="100" Margin="286.769,165.499,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Source=obs}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Name="TextBoxList"></TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
通过这样做,我有一些文本框与可观察集合中的项目相同,但文本框的文本未设置.
最近我注意到一个为特定实体分配id的约定,如果id不在那里,引起我注意的是返回-1.为什么返回-1而不是0?
protected long AcqAgreementID
{
get
{
if(ViewState["AcqAgreementID"] != null)
{
return Convert.ToInt64(ViewState["AcqAgreementID"]);
}
else
{
return -1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
例如,在a部分:我有一个随机数,在b部分:我想将该随机数乘以2,但它必须在一个函数中,然后c:必须添加10,依此类推.我想这对你们来说非常简单.我确信我写的是非常愚蠢的代码,但我不是程序员.
谢谢.
class Program
{
static void Main(string[] args)
{
Boot boot = new Boot();
Game game = new Game();
Console.WriteLine("Matrix Lengte: " + game.Matrix);
Console.WriteLine("Lengte boot: " + boot.Lengte);
Console.ReadLine();
class Game
{
private Boot boot;
private int matrix;
public int Matrix
{
get { return matrix; }
set { matrix = value; }
}
public Game()
{
matrix= boot.Lengte*2;
}
internal Boot Boot
{
get { return boot; }
set { boot = value; }
}
Run Code Online (Sandbox Code Playgroud) 我是C#的新手.textbox1默认是锁定的,我想在检查checkbox1时启用它.我使用以下代码,但它不起作用:
private void checkboxevent(object sender, EventArgs e)
{
if (checkBox1.Checked = true)
textBox1.Enabled = true;
else
textBox1.Enabled = false;
}
Run Code Online (Sandbox Code Playgroud) 我想仅在日期时间之前或今天的日期显示消息.这是我有的:
var todaysdate = DateTime.Today;
if (acct.maturityDate <= todaysdate )
{
maturityText.Visible = true;
}
Run Code Online (Sandbox Code Playgroud)
我收到一条消息说 (acct.maturityDate <= todaysdate ).
无法将运算符'<='应用于'string'和'system.datetime'类型的操作数,候选是bool <=(system.datetime,system.datetime)(在struct datetime中).
任何帮助表示赞赏.
我有一个简单的问题但很难为我做.我有一个日期时间值.
DateTime? Date;
Run Code Online (Sandbox Code Playgroud)
日期有价值4/2/2014.我怎样才能将此值更改为04/02/2014?
什么类型的运算符可用于对象类?
public static void testing()
{
object test = 10;
object x = "a";
object result = test + x;//compiler error
}
Run Code Online (Sandbox Code Playgroud)
为什么我不能+用对象类型?
我知道提交表单数据的两种方法:通过提交类型提交的按钮或通过AJAX发布呼叫.这两个关于绩效的区别是什么?
c# ×9
.net ×2
textbox ×2
wpf ×2
ajax ×1
asp.net-mvc ×1
code-behind ×1
controls ×1
data-binding ×1
datetime ×1
dynamic-list ×1
function ×1
linq ×1
listbox ×1
performance ×1
post ×1