Reputation: 391
I am getting an error message "not all code paths return a value". Can anybody tell me what I missed?
public string AddLineBreak(string str, int column)
{
if (str == null || str.Length == 0)
return "";
}
Upvotes: 0
Views: 37
Reputation: 125726
You missed what happens if the if
isn't true.
public string AddLineBreak(string str, int column)
{
if (str == null || str.Length == 0)
return "";
// What happens if str != null or str.Length != 0?
}
In this case, you can resolve it with a simple return
(presuming you know what you want to return, that is):
public string AddLineBreak(string str, int column)
{
if (str == null || str.Length == 0)
return "";
return WhatEver_AddLineBreak_Using_str_and_column_returns;
}
Upvotes: 1