简体   繁体   English

获取值存储在数组类型为Session的Session变量对象中……System.Collections.Generic.List

[英]getting values is stored in a Session variable object of array type… System.Collections.Generic.List

I want to show values saved in object of array type.. by doing 我想显示保存在数组类型对象中的值。

<body>objname.Names</body>

this gets printed on my HTML page System.Collections.Generic.List`1[System.String] 这被打印在我的HTML页面System.Collections.Generic.List`1 [System.String]

I'm not sure I understand your question. 我不确定我是否理解您的问题。 If you want to print the values of Names you can use this format. 如果要打印名称的值,则可以使用此格式。 Of course objname must be a protected or public member of the Page. 当然objname必须是Page的受保护成员或公共成员。

<body><%= string.Join(", ", objname.Names.ToArray()) %></body>

you should loop at minimum, or use a Data bindable control like DataList, DataGrid, Repeater etc... 您至少应循环播放,或使用可绑定数据的控件,例如DataList,DataGrid,Repeater等。

pseudo code: 伪代码:

foreach(object obj in objName)
{
  Response.Write(String.Format("{0}<br />", obj.ToString())), 
}

of course the result of obj.ToString() depends very much on what kind of objects you have in your array or collection. 当然, obj.ToString()的结果在很大程度上取决于数组或集合中具有哪种对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 键入“对象{System.Collections.Generic.List <T> }“ VS” System.Collections.Generic.List <T> ” - Type “object {System.Collections.Generic.List<T>}” VS “System.Collections.Generic.List<T>” 如何处理类型“ Object {System.Collections.Generic.List <object> }” - How to handle type “Object {System.Collections.Generic.List<object>}” 无法将类型&#39;object [] []&#39;转换为&#39;System.Collections.Generic.List <object> “ - Cannot convert type 'object[][]' to 'System.Collections.Generic.List<object>' 无法将类型为“System.Collections.Generic.List`1[System.Object]”的 object 转换为类型“System.Collections.Generic.List`1” - Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.List`1[customType] 无法将JSON对象反序列化为“System.Collections.Generic.List”类型 - Cannot deserialize JSON object into type 'System.Collections.Generic.List' 无法转换&#39;System.Collections.Generic.List`1类型的对象 - Unable to cast object of type 'System.Collections.Generic.List`1 无法将“System.Collections.Generic.List”类型的 object 转换为“System.Collections.Generic.ICollection”类型 - Unable to cast object of type 'System.Collections.Generic.List to type 'System.Collections.Generic.ICollection 存储过程中的UDT类型:错误-从对象类型System.Collections.Generic.List`1到已知托管提供程序本机类型的映射不存在 - UDT Type in Stored Procedure: Error - No mapping exists from object type System.Collections.Generic.List`1 to a known managed provider native type 无法隐式转换类型&#39;System.Collections.Generic.list <fooClass> &#39;到&#39;System.Collections.Generic.List <T> - Cannot Implicitly convert type 'System.Collections.Generic.list<fooClass>' to 'System.Collections.Generic.List<T> 无法隐式转换类型&#39;System.Collections.Generic.List <AnonymousType#1> &#39;到&#39;System.Collections.Generic.List - Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM