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

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

嗨我试图创建它实际上用vb6编写的缩略图,我将其转换为c#并尝试创建缩略图,当我进行显式转换时它就像上面提到的错误一样。 请有人帮忙。 我尝试过:

hi I tried to create thumbnail its actually written in vb6 , I converted it into c# and trying to create thumbnail , when I do explicit conversion it says like above mentioned error. please someone help. What I have tried:

private bool AddThumbnail() { savdImgCnt = 0; Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback); Panel panel1 = new Panel(); var _with1 = panel1; _with1.Visible = true; _with1.Location = new Point(61, 130); _with1.Name = "panel1"; _with1.Size = new Size(650, 600); _with1.AutoScroll = true; _with1.BorderStyle = BorderStyle.Fixed3D; this.Controls.Add(panel1); int btnposition_X = 0; int btnposition_Y = 0; btnposition_X = 15; btnposition_Y = 10; string strFileSize = ""; Myconnection obj = new Myconnection(); obj.SetConnection(); OleDbCommand cmd = default(OleDbCommand); OleDbDataReader dr = default(OleDbDataReader); cmd = new OleDbCommand("Select * from PresetDetails", obj.con); dr = cmd.ExecuteReader(); if (dr.HasRows == true) { while (dr.Read()) { if (File.Exists("\\saved files\\" + dr[1] + ".bmp")) { btn[savdImgCnt] = new Button(); var _with2 = btn[savdImgCnt]; _with2.Height = 110; _with2.Width = 110; _with2.Visible = true; _with2.Name = dr[1].ToString(); _with2.Location = new System.Drawing.Point(btnposition_X, btnposition_Y); _with2.ForeColor = Color.Chocolate; btn[savdImgCnt].Click += Dynamic_Method; bitmap = new Bitmap("\\saved files\\" + dr[1] + ".bmp"); thmbitmap= bitmap.GetThumbnailImage(100, 100, myCallback, IntPtr.Zero); bitmap.Dispose(); //'thmbitmap.Save(My.Application.Info.DirectoryPath & "\Thumb files\" & dr(0).ToString & ".bmp") btn[savdImgCnt].Image = thmbitmap; //'btn[savdImgCnt].TabIndex = 0; //Controls.Add(btn[savdImgCnt]); label1[0] = new Label(); var _with3 = label1[0]; _with3.AutoSize = true; _with3.Text = dr[1].ToString(); _with3.Location = new System.Drawing.Point(btnposition_X + 35, btnposition_Y + 110); //'Me.Controls.Add(label1(0)) panel1.Controls.Add(label1[0]); label1[1] = new Label(); var _with4 = label1[1]; _with4.AutoSize = true; _with4.Text = dr[2].ToString(); _with4.Location = new System.Drawing.Point(btnposition_X + 1, btnposition_Y + 130); //'Me.Controls.Add(label1(1)) panel1.Controls.Add(btn[savdImgCnt]); panel1.Controls.Add(label1[1]); savdImgCnt = savdImgCnt + 1; btnposition_X = btnposition_X + 150; if (savdImgCnt % 4 == 0) { btnposition_X = 15; btnposition_Y = btnposition_Y + 150; } } } } obj.CloseConnection();

推荐答案

您将方法声明为 bool 但是你没有任何返回语句。 除非您的代码中的每条路线都意味着返回系统将(正确地)抱怨,因为它无法保证将任何值传递给调用者。 将方法更改为 void 输入: You declare the method as a bool but you don't have any return statement. Unless every route through your code means a return the system will (correctly) complain because it cannot guarantee to pass any value back to the caller. Either change your method to a void type: private void AddThumbnail()

或添加返回最后的陈述。

更多推荐

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

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

发布评论

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

>www.elefans.com

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