Click here to Skip to main content
15,867,568 members
Home / Discussions / C#
   

C#

 
AnswerRe: Will calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver9-Apr-22 20:20
pr1mem0ver9-Apr-22 20:20 
GeneralRe: Will calling a new method/property work if called on a "base" abstract object Pin
OriginalGriff9-Apr-22 22:16
mveOriginalGriff9-Apr-22 22:16 
GeneralRe: Will calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver10-Apr-22 6:10
pr1mem0ver10-Apr-22 6:10 
QuestionProblem with BackgroundWorker component? Pin
Member 140558797-Apr-22 1:23
Member 140558797-Apr-22 1:23 
AnswerRe: Problem with BackgroundWorker component? Pin
Richard MacCutchan7-Apr-22 1:41
mveRichard MacCutchan7-Apr-22 1:41 
AnswerRe: Problem with BackgroundWorker component? Pin
Luc Pattyn7-Apr-22 6:30
sitebuilderLuc Pattyn7-Apr-22 6:30 
AnswerRe: Problem with BackgroundWorker component? Pin
Gerry Schmitz7-Apr-22 6:30
mveGerry Schmitz7-Apr-22 6:30 
QuestionC# Exception: An object reference does not point to an instance of an objec Pin
Member 155831391-Apr-22 0:29
Member 155831391-Apr-22 0:29 
Quote:
IDE: Integrated development environment
C#, Visual Studio 2019, Windows10Pro in
2.1
C#

Exception: An object reference does not point to an instance of an object
.


Quote:
using System;
using System.IO;
using System.Text;
// - using System.Text.StringBuilder;
using System.Globalization;
using System.Windows.Forms;

using System.Threading;

// using Microsoft.CSharp;

namespace WFA_BankPercent
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
//- string m_sWork44 = ""; // C# требует инициализации
private void Form7_Load(object sender, EventArgs e)
{

}

// below on forum www.codeproject.com 29032022
private void button21_Click(object sender, EventArgs e)
{
string line = System.String.Empty;
string s_sourse = System.String.Empty;
bool b_beforeRead = false;
bool b_afterRead = false;
string s_begin = "Begin";
string s_end = "End";
bool b_begin = false;
bool b_end = false;
int i_begin = 0;
int i_end = 0;
try
{
StreamReader sr = new StreamReader(@"D:\Input_my.txt");
StreamWriter sw = new StreamWriter("D:\\Out_my.txt", false, Encoding.UTF8);
line = sr.ReadLine();
byte k = 0; // temporary for debug

while (line != null)
{
// k++; // temporary
// //+if (k > 6) // read only the first 6 lines of the input file
////+ if (k > 17) // 15 lines were written to the output file, but there was no Exception
// if (k > 18) // 0 lines were written to the output file, Exception was
// goto Close_my;

if ((line.Trim().Length == 0))
goto label_read;

b_begin = line.Contains(s_begin);
b_end = line.Contains(s_end);

if (b_begin && b_end)
{
i_begin = line.IndexOf(s_begin);
i_end = line.IndexOf(s_end);
s_sourse = line.Substring(0, i_begin);
MessageBox.Show("in line found 'Begin' and 'End'\n" + line);
goto label_wr;
}
else
{
s_sourse = line;
goto label_wr;
}
goto label_read;

label_wr:
sw.WriteLine(s_sourse);
label_read:
b_beforeRead = line.Contains(s_begin);
line = sr.ReadLine();
b_afterRead = line.Contains(s_end);
} // end while (line != null)
Close_my:
line = sr.ReadLine();
MessageBox.Show("Does it get here?" + s_sourse);
sr.Close();
sw.Close();
} // end try
catch (Exception e1)
{
MessageBox.Show("2.1 Exception: " + e1.Message);
}
finally
{
MessageBox.Show("3.Executing finally block.");
}
} // end button21
}
}
C#


AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard Deeming1-Apr-22 0:51
mveRichard Deeming1-Apr-22 0:51 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
OriginalGriff1-Apr-22 0:53
mveOriginalGriff1-Apr-22 0:53 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard MacCutchan1-Apr-22 1:07
mveRichard MacCutchan1-Apr-22 1:07 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Dave Kreskowiak1-Apr-22 2:12
mveDave Kreskowiak1-Apr-22 2:12 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Gary R. Wheeler2-Apr-22 3:21
Gary R. Wheeler2-Apr-22 3:21 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Pete O'Hanlon5-Apr-22 4:03
subeditorPete O'Hanlon5-Apr-22 4:03 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji10-Apr-22 14:20
Raphael Adeniji10-Apr-22 14:20 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji12-Apr-22 3:36
Raphael Adeniji12-Apr-22 3:36 
QuestionAccess Android Tablet from C# Pin
Kevin Marois30-Mar-22 18:23
professionalKevin Marois30-Mar-22 18:23 
AnswerRe: Access Android Tablet from C# Pin
Richard MacCutchan30-Mar-22 22:30
mveRichard MacCutchan30-Mar-22 22:30 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 6:15
professionalKevin Marois31-Mar-22 6:15 
GeneralRe: Access Android Tablet from C# Pin
Richard MacCutchan31-Mar-22 6:19
mveRichard MacCutchan31-Mar-22 6:19 
AnswerRe: Access Android Tablet from C# Pin
OriginalGriff31-Mar-22 3:09
mveOriginalGriff31-Mar-22 3:09 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 6:16
professionalKevin Marois31-Mar-22 6:16 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 8:11
professionalKevin Marois31-Mar-22 8:11 
GeneralRe: Access Android Tablet from C# Pin
OriginalGriff31-Mar-22 19:49
mveOriginalGriff31-Mar-22 19:49 
QuestionError when parsing string as int Pin
Member 1558328029-Mar-22 5:19
Member 1558328029-Mar-22 5: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.