在asp.net 开发中经常使用三元表达式,代码示例如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="lianxi_jiaohu.aspx.cs" Inherits="lianxi_jiaohu.lianxi_jiaohu" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div><%=value%></div>
<div><%=(value== "yes" ? "女朋友同意我晚上去约会" : "女朋友同意我白天去约会")%></div>
<div><%=list.ToString()%></div>
</div>
</form>
</body>
</html>