获取错误:并非所有代码路径都返回值

编程入门 行业动态 更新时间:2024-10-26 16:34:35
本文介绍了获取错误:并非所有代码路径都返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

private static int Abc() { 列表与LT; INT> result = new List< int>(); byte [] numbers = GetValue(); string selectedItems ="" ;; int j = 0; for(int i = 0; i< 18; i ++) { j ++; selectedItems + = numbers [i]; if(j == 3) { result.Add(getDecimal(selectedItems)); j = 0; selectedItems ="" ;; }¥b $ b }¥b $ b Console.WriteLine(); Console.WriteLine(" Result is:"); $ foreach(结果中的var项目) { Console.Write(item); }¥b $ b Console.ReadLine(); }

private static int Abc() { List<int> result = new List<int>(); byte[] numbers = GetValue(); string selectedItems = ""; int j = 0; for (int i = 0; i < 18; i++) { j++; selectedItems += numbers[i]; if (j == 3) { result.Add(getDecimal(selectedItems)); j = 0; selectedItems = ""; } } Console.WriteLine(); Console.WriteLine("Result is:"); foreach (var item in result) { Console.Write(item); } Console.ReadLine(); }

推荐答案

愿这个帮助你

你应该在最后返回int

You should return int at the end

private static int Abc() { int intVal = 0; List<int> result = new List<int>(); byte[] numbers = GetValue(); string selectedItems = ""; int j = 0; for (int i = 0; i < 18; i++) { j++; selectedItems += numbers[i]; if (j == 3) { result.Add(getDecimal(selectedItems)); j = 0; selectedItems = ""; } } Console.WriteLine(); Console.WriteLine("Result is:"); foreach (var item in result) { Console.Write(item); } Console.ReadLine(); return intVal; }

或使用void返回任何内容

or use void to return nothing as

private static void Abc()

最好的问候 Vikram Manjare 请记住点击"标记为答案" ;解决您的问题的回复,并点击"取消标记为答案"如果不。这对阅读此主题的其他社区成员有益。

Best Regards Vikram Manjare Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

更多推荐

获取错误:并非所有代码路径都返回值

本文发布于:2023-11-10 01:18:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   返回值   错误   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!