不能隐含将void类型转换为string [英] cannot implicity convert type void to string

查看:169
本文介绍了不能隐含将void类型转换为string的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下

My code as follows

private void SendBulkSMS()
      {

          string template;
          try
          {
              int iRow;
              for (iRow = 0; iRow < dataGridView1.RowCount; iRow++)
              {
                  if (dataGridView1[0, iRow].Value != DBNull.Value && dataGridView1[0, iRow].Value != null && dataGridView1[0, iRow].Value != null && dataGridView1[0, iRow].Value.ToString() != "0")
                  {
                        template = SendSMS(dataGridView1[0, iRow].Value.ToString());
                  }
              }

          }
          catch (Exception ex1)
          {
              MessageBox.Show(ex1.ToString(), "Error", MessageBoxButtons.OK);
              return;
          }
      }



当我运行上面的代码时显示错误信息如下

不能隐含转换键入void to string。



错误行显示如下;


when i run above code shows error message as follows
cannot implicity convert type void to string.

the error line shows as follows;

template = SendSMS(dataGridView1[0, iRow].Value.ToString());





please帮我。



我怎么能在asp.ent中使用c#。



please help me.

for that how can i do in asp.ent using c#.

推荐答案

大概是 SendSMS()没有返回值,所以你应该像这样使用它:

Presumably SendSMS() does not return a value, so you should be using it like this:
if (dataGridView1[0, iRow].Value != DBNull.Value && dataGridView1[0, iRow].Value != null && dataGridView1[0, iRow].Value != null && dataGridView1[0, iRow].Value.ToString() != "0")
{
   SendSMS(dataGridView1[0, iRow].Value.ToString());
}


这篇关于不能隐含将void类型转换为string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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