• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
一个具有上进心的码农
因为一篇文章中有很多是从很多篇文章中摘取的,请恕我没有一一说明摘取出处,如果没有说明,则该文章默认是摘取,如有侵犯您的权益,请与我联系,将会马上删除。
博客园    首页    新随笔    联系   管理    订阅  订阅

百钱百鸡 LINQ取得现在时间 Trim的解释

代码
百钱百鸡

意思是说:  
  去菜市场买鸡,大鸡3元一只,小鸡1元三只,求怎么才能用100元刚好买100只鸡,要求用任意程序实现!
求达人代码

int y=100/3;
  
for(int i=1;i<y;i++)
  {
  
int a = 100 - 3 * i;
  
if (a * 3 + i == 100)
  {
  Console.WriteLine(
"大:"+i+"金额"+i*3+" 小:"+3*a+"金额"+a);
  Console.ReadLine();
  }
  } 



使用linq时怎么获得服务器时间
var obj 
= (from d in db.DEF_Product where CredateDate>Getdate() select d);
            
return obj.ToList<Product, DEF_Product>(Populate);
  [Function(Name 
= "GetDate", IsComposable = true)]
        
public DateTime GetDate()
        {
            MethodInfo mi 
= MethodBase.GetCurrentMethod() as MethodInfo;
            
return (DateTime)this.ExecuteMethodCall(this, mi, new object[] { }).ReturnValue;

        }

        [Function(Name 
= "Reverse", IsComposable = true)]
        
public string Reverse(string str)
        {
            MethodInfo mi 
= MethodBase.GetCurrentMethod() as MethodInfo;
            
return (string)this.ExecuteMethodCall(this, mi,
            
new object[] { str }).ReturnValue;
        }



String.Trim()方法会去除字符串两端,不仅仅是空格字符,它总共能去除25种字符: 
(
'\t', '\n', '\v', '\f', '\r', ' ', '\x0085', '\x00a0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '?', '\u2028', '\u2029', ' ', '?')


如果你想保留其中的一个或多个(例如\t制表符,\n换行符,\r回车符等),请慎用Trim方法。

请注意,Trim删除的过程为从外到内,直到碰到一个非空白的字符为止,所以不管前后有多少个连续的空白字符都会被删除掉。

果想去除字符串两端其他任意字符,可以考虑Trim他的重载兄弟:String.Trim(Char[])

 

posted @ 2010-12-21 09:39  不若相忘于江湖  阅读(356)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3