是否有类似的东西:
AppDomain.CurrentDomain.GetAssemblyByName("TheAssemblyName")
Run Code Online (Sandbox Code Playgroud)
因此AppDomain.CurrentDomain.GetAssemblies()
,我们可以直接获取特定的程序集,而不是循环.
我计划创建我的应用程序并使用ORM作为模型,但问题是,数据库的一部分使用实体 - 属性 - 值表.
我非常喜欢Doctrine ORM,但我不知道是否有可能创建类似于任何普通教义实体的类,当表实际连接到EAV风格时.
是否可以在此使用Doctrine,如果可以,如何使用?
例如,我们在转发器数据源上有19个项目.我们想用
5个项目分开它们.
就像是
01 02 03 04 05 <br />
06 07 08 09 10 <br />
11 12 13 14 15 <br />
16 17 18 19
Run Code Online (Sandbox Code Playgroud)
我们如何在asp.net转发器中执行此操作?谢谢.
例如,我需要查看字符串是否包含子字符串,所以我只是这样做:
String helloworld = "Hello World";
if(helloworld.Contains("ello"){
//do something
}
Run Code Online (Sandbox Code Playgroud)
但如果我有一系列的项目
String helloworld = "Hello World";
String items = { "He", "el", "lo" };
Run Code Online (Sandbox Code Playgroud)
我需要在String类中创建一个函数,如果数组中的任何一个项包含在字符串中,它将返回true.
我想为这个场景覆盖包含(IEnumerable)函数Contains(string),而不是在另一个类中创建一个函数.是否可以这样做,如果是这样,我们如何覆盖这个功能?非常感谢你.
所以这里是完整的解决方案(谢谢你们):
public static bool ContainsAny(this string thisString, params string[] str) {
return str.Any(a => thisString.Contains(a));
}
Run Code Online (Sandbox Code Playgroud) 所以我尝试了GetType(),但由于某种原因,它确实包含了命名空间...
C#没有指定其名称的类的属性吗?
例如:
public class Parent : System.Web.UI.UserControl {
public someFunction(){
Child child = new Child();
Console.WriteLine(child.ThePropertyThatContainsTheName);
}
}
public class Child : Parent {
}
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用名称为硬编码的字符串属性创建Child,但前提是我们可以找到更好的解决方法...也许是反射或表达式......
在此先感谢=)
编辑:顺便说一下我正在处理用户控件...
我们已经创建了具有所有关系和依赖关系的数据库框架.但是在表格内部只是虚拟数据,我们需要摆脱这些虚拟数据,并开始添加正确的数据.我们如何清除所有内容并将主键(IsIdentity:yes)保留为零,并且不会影响外表关系结构.
非常感谢!
在base.master上:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Base.master.cs" Inherits="WebApplicationControlTest.Base" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>The title</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
There is a content here: <br />
<asp:ContentPlaceHolder ID="body" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在嵌套的主人身上
<%@ Master Language="C#" MasterPageFile="~/MasterPages/Base.Master" AutoEventWireup="true" CodeBehind="NestedMasterPageTest2.master.cs" Inherits="WebApplicationControlTest.MasterPages.NestedMasterPageTest2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="PlaceHolder" ContentPlaceHolderID="body" runat="server">
This is inside the NestedPage<br />
<asp:ContentPlaceHolder ID="PlaceHolderLeft" runat="server">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="PlaceHolderRight" runat="server">
</asp:ContentPlaceHolder> …
Run Code Online (Sandbox Code Playgroud) $(textBox).focus( function() {
$(spans).css({"background-position": "0 100%"});
});
$(textBox).blur( function() {
$(spans).css({"background-position": "0 0"});
});
Run Code Online (Sandbox Code Playgroud)
这已经很短了,但要么我太偏执了,要么我们可以将它编码得更短
$(textBox).bind('focus blur', function() { *do toggle here* });
Run Code Online (Sandbox Code Playgroud)
或者是其他东西.
任何帮助将不胜感激.=)
我有一个功能:
private string GetPropertyName(Expression<Func<object, object>> f) {
if ((f.Body as MemberExpression) != null) {
return (f.Body as MemberExpression).Member.Name;
}
return "";
}
Run Code Online (Sandbox Code Playgroud)
它以这种方式使用:
string x1 = GetPropertyName(x => Property1);
string x2 = GetPropertyName(x => Property2);
string x3 = GetPropertyName(x => Property3);
Run Code Online (Sandbox Code Playgroud)
其中Property1是一个int,Property2是一个字符串,Property3是一个对象......
只有正确返回类型字符串和对象的Property2和Property3的名称,但Property1的f.Body作为MemberExpression为空...
为什么会这样,我们如何更改代码,以便函数正确返回属性的名称?
我正在研究一个关于pascal三角形的java程序.
所以这就是它的编码方式:
for(int i = 0; i < 5; i++){
for(int j = 0, x = 1; j <= i; j++){
System.out.print(x + " ");
x = x * (i - j) / (j + 1);
}
System.out.println();
}
Run Code Online (Sandbox Code Playgroud)
它显示:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
但是当我尝试将代码更改为:
for(int i = 0; i < 5; i++){
for(int j = 0, x = 1; j <= i; j++){
System.out.print(x + " ");
x …
Run Code Online (Sandbox Code Playgroud) public List<string> Attributes = new List<string>();
public void Add(string key, string value)
{
if (value.ToString() != "")
{
Attributes.Add(key + "=\"" + value + "\" ");
}
}
public void Add(string key, int value)
{
if (value.ToString() != "")
{
Attributes.Add(key + "=\"" + value + "\" ");
}
}
Run Code Online (Sandbox Code Playgroud)
那么,我们可以只制作一个Add函数而不是两个Add函数吗?例如
public void Add(string key, <var> value)
{
if (value.ToString() != "")
{
Attributes.Add(key + "=\"" + value + "\" ");
}
}
Run Code Online (Sandbox Code Playgroud) 我不确定我是否正确地提出了这个问题.如果我错了,请纠正我.
无论如何,我们想在页面生命周期的不同阶段使用变量的值.
所以,例如,
public partial class TestUserControl: UserControl{
public TestUserControl(){
Objects = new List<object>(){
Property1,
Property2,
Property3
};
}
public int Property1 { get; set; }
public bool Property2 { get; set; }
public string Property3 { get; set; }
public List<object> Objects { get; set; }
protected override OnLoad(EventArgs e){
foreach(var item in Objects){
Page.Controls.Add(new LiteralControl(item.ToString() + "<br/>"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
因此,如果我们说Property1,Property2,Property3的值是在标记上写的那样设置的,那么我们如何才能在需要时使用属性的值?
在构造函数上,而不是属性的值将在列表中列出,只有属性的名称将被列出,因此它们的当前值将用于OnLoad.
非常感谢.
public partial class TestUserControl: UserControl{
public TestUserControl(){
Objects = List<Func<object>>{
() => Property1,
() …
Run Code Online (Sandbox Code Playgroud) c# ×6
c#-4.0 ×2
properties ×2
.net ×1
asp.net ×1
assemblies ×1
classname ×1
database ×1
doctrine ×1
expression ×1
findcontrol ×1
function ×1
gettype ×1
java ×1
javascript ×1
jquery ×1
master-pages ×1
operators ×1
optimization ×1
orm ×1
overloading ×1
php ×1
reflection ×1
repeater ×1
sealed ×1
sql-server ×1
string ×1
types ×1