📄 string.aspx
字号:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="String.aspx.cs"
Inherits="ClientScripting_TypeExtensions_String" Title="String Type Extensions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">
var a = " abc ";
// 同 C#
document.write(a.startsWith("a"));
document.write(" ");
document.write(a.endsWith("c"));
document.write("<br />");
a = a.trimStart();
document.write(a.startsWith("a"));
document.write("<br />");
a = a.trimEnd();
document.write(a.endsWith("c"));
document.write("<br />");
a = " " + a + " ";
a = a.trim();
document.write(a.startsWith("a"));
document.write(" ");
document.write(a.endsWith("c"));
document.write("<br />");
var user =
{
Name: "webabcd",
Birthday: new Date(1980, 2, 14)
};
// String.localeFormat();
document.write(String.format("Name:{0},Birthday:{1:yyyy-MM-dd}", user.Name, user.Birthday));
document.write("<br />");
// 自定义格式化的实现
Type.registerNamespace('Demo');
Demo.CustomFormattedString = function()
{
}
Demo.CustomFormattedString.prototype =
{
// 实现toFormattedString方法,从而实现自定义格式化
toFormattedString: function(format)
{
return "自定义格式化:" + format;
}
}
Demo.CustomFormattedString.registerClass('Demo.CustomFormattedString');
document.write(String.format("{0:测试信息}", new Demo.CustomFormattedString()));
</script>
</asp:Content>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -