Linq很棒,但似乎总是让我感到困惑.
这是我最近的困惑:
说我有两个List<String>对象.我们会打电话给他们sourceList,并destList.
我需要一种方法来查找sourceList中而不是destList中的字符串列表,并找到destList中而不是SourceList中的字符串列表.
这有点令人困惑,所以这里是一个例子:
sourceList destList
Orange
Apple Apple
Grape Grape
Kiwi
Banana
所以我要找的第一个结果就是带有Orange的列表.第二个结果是其中包含Kiwi和Banana的列表.
知道如何用Linq做到这一点?
你如何查询a List<string[]>获取其子阵列上具有匹配项的数组的索引并获得类型的返回System.Collections.Generic.IEnumerable<string[]>?
编辑:
我有这个:
string[] report = File.ReadAllLines(@".\REPORT.TXT").AsQueryable().Where(s
=> s.StartsWith(".|")).ToArray();
List<string[]> mylist = new List<string[]>();
foreach (string line in report)
{
string[] rows = line.Split('|');
mylist.Add(rows);
}
Run Code Online (Sandbox Code Playgroud)
我得到什么来获取行[5] =="foo"的mylist索引
我正在检查JSLint,一些规则激起了我的兴趣.特别是这个:
禁止==和!=
禁止++和 -
为什么禁止这些不好主意?我理解第一部分,基本上它要我做===而不是==. 我不明白为什么. 我理解两者之间的区别,我只是想知道为什么这是不好的做法.有时我真的想这样做==,以便它会评估为真undefined == null
第二个,我根本不明白.它是否要我做myInt + = 1而不是myInt ++?
谢谢!
当我尝试访问shared preference扩展的类中的from 时,我收到错误View.
错误:" The method getSharedPreferences(String, int) is undefined for the type ViewforRed",
ViewforRed是我的班级
这是示例代码
public class ViewforRed extends View
{
public final String PREFS_NAME = "GRAPHICS";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
public ViewforRed(Context context)
{
super(context);
}
public void onDraw(Canvas canvas)
{
Paint paint = new Paint();
float p0,p1,p2,p3,p4,p5,p6,p7,p8,p9;
}
}
Run Code Online (Sandbox Code Playgroud) 我正试图绕过AOP,一些Qt代码真的会有所帮助.
从维基百科这里有一些示例代码(很容易让Qt/C++程序员阅读):
void transfer(Account fromAcc, Account toAcc, int amount, User user, Logger logger)
throws Exception {
logger.info("transferring money...");
if (! checkUserPermission(user)){
logger.info("User has no permission.");
throw new UnauthorizedUserException();
}
if (fromAcc.getBalance() < amount) {
logger.info("Insufficient Funds, sorry :( ");
throw new InsufficientFundsException();
}
fromAcc.withdraw(amount);
toAcc.deposit(amount);
//get database connection
//save transactions
logger.info("Successful transaction. :) ");
}
Run Code Online (Sandbox Code Playgroud)
然后"aspectized":
void transfer(Account fromAcc, Account toAcc, int amount) throws Exception {
if (fromAcc.getBalance() < amount) {
throw new InsufficientFundsException();
}
fromAcc.withdraw(amount);
toAcc.deposit(amount);
} …Run Code Online (Sandbox Code Playgroud) 在大多数情况下shape.Parent,幻灯片包含形状.
但是,如果您尝试删除一个组,然后按下撤消(形状将重新出现),但子形状将为两个.Parent和组件抛出异常.ParentGroup.
如何在上面的案例中找到形状的幻灯片ID?
我在循环中使用setattr()函数赋值:
for i in range(30):
for j in range(6):
setattr(self, "e"+str(i)+str(j), Entry(self.top))
Run Code Online (Sandbox Code Playgroud)
,然后我想申请.grid()函数.用循环来表示所有这些变量.
例如,
self.e00.grid(row= 0, column= 0)
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我正在使用使用Forms身份验证的Web应用程序.
<authentication mode="Forms">
<forms slidingExpiration="true"
loginUrl="~/User.aspx/LogOn"
timeout="15"
name="authToken" />
</authentication>
Run Code Online (Sandbox Code Playgroud)
我登录时在浏览器中看到此cookie设置:

问题是当我将这个网站置于负载均衡模型时会发生什么?ASP.net会话cookie在哪里设置?我没有在代码中明确地做到这一点,所以我认为它发生在ASP.Net的某个幕后.
此外,如果会话cookie由Web服务器A设置,我假设Web服务器B将无法识别它并将其视为无效会话.如果是这种情况,我可能不想使用它,对吧?
我对CSS的极度沮丧是它无法在不同的浏览器(以及不同版本的浏览器 - 很好地工作 - 是的,我在谈论你的IE).
人们遇到的CSS框架是什么,以及它们的具体优势是什么?我今天听说过面向对象的CSS框架,但我还没有时间研究它.