我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我 [英] I am novice to linq..I want to concatenate the strings ..How can we concatenate the strings for the below query..help me

查看:78
本文介绍了我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处LicenseId为整数..



var q =(来自salesContext.SL_License中的b,其中b.OrderId == 254857选择新{b.LicenseId}) .ToList();

解决方案

你可以使用 string.Join

< pre lang =c#> var q =(.....)。ToList();
var res = string .Join( ,q);


LINQ Aggregate 可用于连接字符串的扩展方法。

  string  [] array = {  a  b}; 
var output = array.Aggregate((a,b)= > a + b );





以下是一些例子 -

C#聚合方法 [ ^ ]

有关聚合方法的更多信息 [ ^ ]


here LicenseId is Integer..

var q = (from b in salesContext.SL_License where b.OrderId == 254857 select new { b.LicenseId}).ToList();

解决方案

you can use string.Join

var q = (.....).ToList();
var res = string.Join(",",q);


LINQ has an Aggregate extension method that can be used to concatenate strings.

string[] array = { "a", "b"};
    var output = array.Aggregate((a, b) => a + b);



Here are some more examples -
C# Aggregate method[^]
More on the Aggregate method[^]


这篇关于我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆