Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: Please answer it is my biggest problem. Pin
Richard MacCutchan4-Dec-13 22:13
mveRichard MacCutchan4-Dec-13 22:13 
AnswerRe: Please answer it is my biggest problem. Pin
WuRunZhe9-Dec-13 2:42
WuRunZhe9-Dec-13 2:42 
Questionif/then/else variable frustration Pin
Steve Embry4-Dec-13 9:56
Steve Embry4-Dec-13 9:56 
AnswerRe: if/then/else variable frustration Pin
Pete O'Hanlon4-Dec-13 10:07
mvePete O'Hanlon4-Dec-13 10:07 
GeneralRe: if/then/else variable frustration Pin
Steve Embry4-Dec-13 15:09
Steve Embry4-Dec-13 15:09 
GeneralRe: if/then/else variable frustration Pin
DRAYKKO5-Dec-13 8:05
professionalDRAYKKO5-Dec-13 8:05 
AnswerRe: if/then/else variable frustration Pin
Mycroft Holmes4-Dec-13 11:53
professionalMycroft Holmes4-Dec-13 11:53 
Questionif/then/else variable frustration Pin
Steve Embry4-Dec-13 9:51
Steve Embry4-Dec-13 9:51 
Hello-

I'm fairly new to C# (classic ASP guy), and I'm having a heckuva time with this. I am hoping someone can point out my flawed logic.

I first need to ascertain if the current article group is one of several that need to be treated differently. If it is, it defines the var "strbody" using a complete value as retrieved from the database. If it is not one of those special article groups, then I have to do some string manipulation to format the retrieved value before defining and displaying it.

My string manipulation code is flawless, but neither of the strbody vars I define in my if/then/else block is recognized when I call it below the code block???

C#
@{
string group = Model.ArticleGroupName;

if (group.Contains("Spacial Orientation")||group.Contains("Topography")||group.Contains("Osteology")||group.Contains("Angiology")||group.Contains("Neurology")||group.Contains("Myology")||group.Contains("Radiology")||group.Contains("Misc. Drawings")||group.Contains("Clinical Testing"))
    {
    var strbody = item.ShortBody;
    }
    else
    {

    string s = item.ShortBody;
    string sLess = s.Remove(0, 12);
    int index = sLess.IndexOf("Summary");
    var strbody = (sLess.Substring(index + 8));
    }
}
@strbody



That code results in the following error:

\Plugins\FoxNetSoft.Articles\Views\ArticleRead\List.cshtml(76): error CS0103: The name 'strbody' does not exist in the current context

I am new to this, so please don't hesitate to chastise me for doing dumb stuff...I need to learn!

Thanks,
Steve
AnswerRe: if/then/else variable frustration Pin
s_magus4-Dec-13 10:08
s_magus4-Dec-13 10:08 
GeneralRe: if/then/else variable frustration Pin
Steve Embry4-Dec-13 15:07
Steve Embry4-Dec-13 15:07 
GeneralRe: if/then/else variable frustration Pin
s_magus4-Dec-13 16:34
s_magus4-Dec-13 16:34 
GeneralRe: if/then/else variable frustration Pin
Steve Embry4-Dec-13 16:57
Steve Embry4-Dec-13 16:57 
GeneralParameterized Queries Pin
BBatts4-Dec-13 3:17
BBatts4-Dec-13 3:17 
GeneralRe: Parameterized Queries Pin
Simon_Whale4-Dec-13 3:23
Simon_Whale4-Dec-13 3:23 
GeneralRe: Parameterized Queries Pin
PIEBALDconsult4-Dec-13 4:19
mvePIEBALDconsult4-Dec-13 4:19 
GeneralRe: Parameterized Queries Pin
Eddy Vluggen4-Dec-13 7:07
professionalEddy Vluggen4-Dec-13 7:07 
GeneralRe: Parameterized Queries Pin
BBatts5-Dec-13 2:22
BBatts5-Dec-13 2:22 
Questionanyone tried Xamarin? Pin
Jassim Rahma4-Dec-13 3:04
Jassim Rahma4-Dec-13 3:04 
AnswerRe: anyone tried Xamarin? Pin
thatraja4-Dec-13 3:47
professionalthatraja4-Dec-13 3:47 
QuestionUpdate stored procedure doesn't update, it keeps on saying info modification fails, please help Pin
Member 103378794-Dec-13 1:00
Member 103378794-Dec-13 1:00 
AnswerRe: Update stored procedure doesn't update, it keeps on saying info modification fails, please help Pin
Chris Quinn4-Dec-13 1:05
Chris Quinn4-Dec-13 1:05 
AnswerRe: Update stored procedure doesn't update, it keeps on saying info modification fails, please help Pin
Simon_Whale4-Dec-13 1:12
Simon_Whale4-Dec-13 1:12 
AnswerRe: Update stored procedure doesn't update, it keeps on saying info modification fails, please help Pin
toyfercho4-Dec-13 6:13
toyfercho4-Dec-13 6:13 
QuestionRegarding app.config in windows application Pin
tarun kumar sahu hs4-Dec-13 0:52
tarun kumar sahu hs4-Dec-13 0:52 
AnswerRe: Regarding app.config in windows application Pin
Colin Angus Mackay4-Dec-13 1:19
Colin Angus Mackay4-Dec-13 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.