如果我覆盖System.Web.UI.Page构造函数,如图所示,DoSomething()何时在页面生命周期中被调用?我似乎无法在任何地方找到这个记录.
namespace NameSpace1
{
public partial class MyClass : System.Web.UI.Page
{
public MyClass()
{
DoSomething();
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
供参考,这是ASP.NET页面生命周期概述:
http://msdn.microsoft.com/en-us/library/ms178472.aspx
结果是MSDN文章中的最佳答案.我只需要仔细查看图表.构造是页面生命周期中的第一个事件(在PreInit,Init,Load等之前).
我想在括号之间提取文本 - 也不是括号!
我的代码看起来像这样:
var source = "Harley, J. Jesse Dead Game (2009) [Guard]"
// Extract role with regex
m = Regex.Match(source, @"\[(.*)\]");
var role = m.Groups[0].Value;
// role is now "[Guard]"
role = role.Substring(1, role.Length-2);
// role is now "Guard"
Run Code Online (Sandbox Code Playgroud)
你能帮我把它简化为一个正则表达式,而不是正则表达式,然后是子串吗?