关于完整解答Leo C.W博客中名为“我们公司的ASP.NET 笔试题,你觉得难度如何”的所有题目

时间:2023-01-15 13:41:12

关于完整解答Leo C.W博客中名为“我们公司的ASP.NET 笔试题,你觉得难度如何”的所有题目,请大家鉴定,不足之处,敬请指教!

第1到3题解答如下:

    public enum QuestionType
{
Text = ,
MultipleChoice =
} public interface IQuestion
{
string Title { get; set; }
QuestionType Category { get; }
string GetAnswer();
} public abstract class QuestionBase : IQuestion
{
public string Title { get; set; }
public abstract QuestionType Category { get; } public virtual string GetAnswer()
{
return "默认答案";
} } public class TextQuestion : QuestionBase
{
public override QuestionType Category { get { return QuestionType.Text; } } public override string GetAnswer()
{
return "文本答案";
}
} public class MultipleChoiceQuestion : QuestionBase
{
public override QuestionType Category { get { return QuestionType.MultipleChoice; } } public override string GetAnswer()
{
return "单选答案";
}
}

第4题:

    public class Product
{
public string Name { get; set; }
public string IsDeleted { get; set; }
} public static class ProductExtension
{
public static IQueryable<Product> WhereNotDeleted(this IQueryable<Product> query)
{
return query.Where(p => p.IsDeleted != "是");
}
} public class ProductService
{
public List<Product> GetActiveProducts(IQueryable<Product> query)
{
return query.WhereNotDeleted().ToList();
}
}

第5

select T1.Name,T2.[Year],T2.[Month],T2.InCome from [User] as T1 inner join
(select UserId,[Year],[Month],COUNT(Amount) AS InCome from InCome group by UserId,[Year],[Month]) as T2
on T1.Id=T2.UserId
order by T2.UserId,T2.[Year],T2.[Month]
select T1.Name,T2.[Year],T2.[Month],COUNT(T2.Amount) AS InCome from [User] as T1
inner join InCome as T2 on T1.Id=T2.UserId
group by T1.Name,T2.[Year],T2.[Month] order by T1.Name,T2.[Year],T2.[Month]

第6题:

    public class User
{
public int Id { get; set; }
public string Name { get; set; }
} public class Income
{
public int Id { get; set; }
public int UserId { get; set; }
public decimal Amount { get; set; }
public int Year { get; set; }
public int Month { get; set; }
} public class UserIncomeDto
{
public string Name { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public decimal Income { get; set; }
} public class UserIncomeService
{
public List<UserIncomeDto> GetUserIncomeDtos(IQueryable<User> users, IQueryable<Income> incomes)
{
var resultList = (from u in users
join newic in
(from ic in incomes
group ic by new { ic.UserId, ic.Year, ic.Month } into gp
select new { gp.Key, InCome = gp.Sum(g => g.Amount) })
on u.Id equals newic.Key.UserId
orderby newic.Key
select new UserIncomeDto() { Name = u.Name, Year = newic.Key.Year, Month = newic.Key.Month, Income = newic.InCome }).ToList(); return resultList;
}
}

第7

改HTML:

<form action="/admin/mobile/user/login" method="POST">
<input type="text" placeholder="username" name="username" />
<input type="password" placeholder="password" name="password" />
<input type="submit" value="login" />
</form>

改路由:

            routes.MapRoute("UserLogin",
"~/admin/mobile/{controller}/{action}",
new { controller = "User", action = "Login" });

第8题:

    public class Product1
{
public string Name { get; set; }
public string Description { get; set; } public void Validate1()
{
if (string.IsNullOrEmpty(this.Name))
{
throw new Exception("please enter a name for the product");
}
if (string.IsNullOrEmpty(this.Description))
{
throw new Exception("product description is required");
}
} public void Validate2()
{
this.Require(x => x.Name, "please enter a name for the product");
this.Require(x => x.Description, "product description is required");
} public void Require(Expression<Func<Product1, string>> expression, string errorMessage)
{
Func<Product1, string> func = expression.Compile(); if (string.IsNullOrEmpty(func(this)))
{
throw new Exception(errorMessage);
}
}
} public class TestProgram
{
public static void Main()
{
Product1 product1 = new Product1();
try
{
product1.Validate2();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.Read();
}
}

更多IT相关的文章,欢迎光临我的个人网站:http://www.zuowenjun.cn/

关于完整解答Leo C.W博客中名为“我们公司的ASP.NET 笔试题,你觉得难度如何”的所有题目的更多相关文章

  1. 欢迎阅读daxnet的新博客:一个基于Microsoft Azure、ASP&period;NET Core和Docker的博客系统

    2008年11月,我在博客园开通了个人帐号,并在博客园发表了自己的第一篇博客.当然,我写博客也不是从2008年才开始的,在更早时候,也在CSDN和系统分析员协会(之后名为"希赛网" ...

  2. 修复在&OpenCurlyDoubleQuote;Android 在ScrollView中嵌入ViewPage后ViewPage不能很好的工作的问题解决”这篇博客中MyScrollView出现滑动一会就不会上下滑动的问题

    在“Android 在ScrollView中嵌入ViewPage后ViewPage不能很好的工作的问题解决”,这篇博客中的大部分问题已经解决了. 唯一遗憾的是,ViewPage随人能够工作了,但是My ...

  3. 带图片的word快速插入到博客中

    最近在博客中写文章的时候,最烦的就是将word文档整体传到博客中,不能一次把图片粘贴上去,再次去添加图片的时候要截图还要找对位置才可上传,偶尔的机会在网上看到有人这么处理,挺好用的,这里我也做个备注. ...

  4. 在博客中显示图片&lowbar;Mac版

    主要是防止自己忘掉 为了解决一开始自己想在写入的博客中添加本地图片,直接链接的话在自己的电脑倒是可以显示图片,但是在别人的电脑上就没办法加载图片了,问各路大神也没人愿意解答,百度也没有想要的答案,只好 ...

  5. 借用Snippet插件美化博客中的代码

    书写博客,难免要贴出代码.然而直接贴出代码,则不美观.于是,应运而生出现了很多代码美化的插件.其中比较有名的是Syntax Highlighting插件.   笔者在网上翻阅的时候发现了Snippet ...

  6. 在hexo静态博客中利用d3-cloud来展现标签云

    效果: http://lucyhao.com/tags/ hexo自带的tag cloud的标签展现不太美观,想能够展现出“云”效果的标签.在网上找到了d3-cloud这个项目,github地址:ht ...

  7. CSDN博客排名第一名,何许人也

    CSDN博客排名第一名,何许人也 一.提出问题 CSDN博客排名第一名,何许人也. 分析截止时间是:2013年12月19日星期四22:00. 二.博客网址 http://blog.csdn.net/p ...

  8. 2015年CSDN博客排名第一名,何方神圣?

    2015年CSDN博客排名第一名,何方神圣? 一.引子: 话说博主phphot,雄霸天下好多年. 俱往矣, 落花流水春去也. 斗转星移,*易主. 详细可以参见下文: CSDN博客排名第一名,何许人也 ...

  9. 在个人博客中优雅的使用Gitalk评论插件

    在上一篇博客<程序员如何从0到1搭建自己的技术博客>中,我们了解了如何快速的从0到1搭建一个个人博客. 其实细心的你会发现,该博客用到了一个评论插件,这个插件就是Gitalk. 如果想要在 ...

随机推荐

  1. xcode6&period;0 模拟器打不开

      只要设置下这个就行了 本来以为虚拟机的问题  都把虚拟机从新安装了 杯具啊

  2. 由一个activity跳转到另一个activity

    定义一个按钮,当点击的时候跳转到另一个activity的界面 1.新建第二个activity 2.在第二个Java源码处继承第一个activity,导入 3.在source中复写Oncreat方法 4 ...

  3. Jedis的JedisSentinelPool源代码分析

    概述 Jedis是Redis官方推荐的Java客户端,更多Redis的客户端可以参考Redis官网客户端列表.Redis-Sentinel作为官方推荐的HA解决方案,Jedis也在客户端角度实现了对S ...

  4. HTML本地测试成功后上传博客注意事项

    需要注意不要跟博客已经存在的样式(CSS)或功能(JavaScript)起冲突 功能名一定不要一样 样式名尽量不一样 如果样式名一样,存在属性名的对应属性值尽量跟博客内相同

  5. EF连接MySQL数据Web&period;Config配置

    EF连接MySQL数据Web.Config配置 <?xml version="1.0" encoding="utf-8"?> <configu ...

  6. 报表学习总结(一)——ASP&period;NET 水晶报表&lpar;Crystal Reports&rpar;的简单使用

    一.水晶报表简介 Crystal Reports(水晶报表)是一款商务智能(BI)软件,主要用于设计及产生报表.水晶报表是业内最专业.功能最强的报表系统,它除了强大的报表功能外.最大的优势是实现了与绝 ...

  7. 零基础学Python--------第7章 面向对象程序设计

    第7章 面向对象程序设计 7.1 面向对象概述 面向对象(Object Oriented)的英文缩写是OO,它是一种设计思想.从20世纪60年代提出面向对象的概念到现在,它已经发展成为一种比较成熟的编 ...

  8. 函数指针的返回值是指针数组,数组里放的是int;函数指针的返回值是指针数组,数组里放的是int指针

    函数指针的返回值是指针数组,数组里放的是int 函数指针的返回值是指针数组,数组里放的是int指针 #include <stdio.h> #include <stdlib.h> ...

  9. JS实现继承的6种方式

    使用pretotype,call实现完美继承 父类: fuction Animal(name){     this.name=name||"Animal";     this.sl ...

  10. 实验三:C分支结构程序设计

    3.1 #include<stdio.h> int main(){ char a; scanf("%c",&a); if(a>=65&&a ...