如何从这里获取标题数字? [英] How to I get the header numbers from here?

查看:61
本文介绍了如何从这里获取标题数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从c#中的xml响应中获取标题号。在我的MVC控制器上



这就是我在xml中使用系统所拥有的


;

使用System.Collections.Generic;

使用System.Xml;





for (int i = 0; index< heads.Count; i ++)

{

XmlNode header = headers [index];



if(heads.Attributes [default]!= null)

{

DefaultHeaders = heads.InnerText;

}



一旦获取c#上的数字,我想查找超过2位的数字。我该怎么做呢?我正在考虑使用for循环?



我想要的c#代码假设是在我使用MVC时进入控制器。







我想获取超过5位数的第一个标题





我需要做的就是获取超过5位数的第一个标题...我想让它在我的控制器上,因为我正在使用mvc 5 ....所以在xml请求上给出该标题我想查找超过5位数的第一个标题...或者如果它是默认值,则给我默认的数字标题



我尝试了什么:



i想要循环读取数字?

I want to get the header numbers from the xml response in c#. On my MVC Controller

this is what i have in the xml

using System;
using System.Collections.Generic;
using System.Xml;


for(int i = 0; index < heads.Count; i++)
{
XmlNode header = headers[index];

if (heads.Attributes["default"] != null)
{
DefaultHeaders = heads.InnerText;
}

once it fetches for the numbers on c# i want to look for the number that have more than 2 digits. How do i do this? i was thinking to use a for loop?

the c# code that i want in return is suppose to go in the controller as i am using MVC.



I want to fetch the first header with more than 5 digits


All i need to do is to fetch for the first header that has more than 5 digits...i want it to have it on my controller as i am using mvc 5....so giving that header on the xml request i want to look for the first header that has more than 5 digits...or if it a default, to give me the default number header

What I have tried:

i was thinking of loooking for the numbers with a loop?

推荐答案

您的代码很奇怪,使用调试器来查看您的代码正在做什么:

Your code is weird, use the debugger to see what your code is doing exactly:
for(int i = 0; index < heads.Count; i++)





你应该学会尽快使用调试器。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。 />
调试器中没有魔法,它没有发现错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。



You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于如何从这里获取标题数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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