Questions tagged as 'c#'

2
answers

How to pass control values between different windows?

And I have a question here about programming in C #, which I'm not sure how to do. Well, I'm first with a Windows Form Application C # program, in it I created 2 forms, form1 being the main one, where there is a menu that would be to choose a...
asked by 29.07.2014 / 05:20
1
answer

Doubt with XML file creation

I have a program that creates an XML file using XmlTextWriter, following the example public static void testeGerarXml() { using (var xml = new XmlTextWriter(@"c:\Gustavo\teste.xml", Encoding.UTF8)) { xml.WriteStartDocument();...
asked by 04.04.2017 / 21:23
1
answer

Conditional optimization

Is it possible to make a comparison (if equal to 1 or equal to null ) simpler than the one made in my code? @((Model.Visibilidade == 1 || Model.Visibilidade == null) ? "checked" : "")     
asked by 29.03.2017 / 14:49
1
answer

Redirect to View in another structure

I have a project, which is in an area, in it, my main controller, has an action that, when called, should return a view that is in another folder, but within the same area. return View("OutraPasta/Index.cshtml"); return View("~/Views/OutraPas...
asked by 27.03.2017 / 22:08
1
answer

How to simplify a foreach by a Linq - Lambda expression

Performance is not a problem in my project, I want to know a simpler and readable replacement for my foreach using Linq and Lambda (if possible). // 'DiscoVirtual' é uma classe // 'this.HDs' é um 'List<DiscoVirtual>' // 'Atual' e 'Novo'...
asked by 23.08.2015 / 19:27
2
answers

Find out if a control is a button

I have the following code to change the color of the buttons that are in a panel: private void mudaCorBotao(Button bt) { foreach(Control b in Panel_esq.Controls) { if (/*[O que devo colocar aqui?]*/) { b.Bac...
asked by 23.04.2017 / 01:43
1
answer

Pass image to HTML via ViewBag

I have an image in an array of bytes, and I need to insert it into view . Is there any way I can do this through ViewBag ?     
asked by 10.04.2017 / 16:50
2
answers

Problem in running tasks with two buttons in the same form in C #

I'm new to C #, so forgive some rookie error. I need to put two buttons on the same form, one to call one form, and another to execute a function I'm trying like this: private void button1_Click(object sender, EventArgs e) { d...
asked by 03.05.2017 / 06:40
1
answer

Class C # as parameter in SQL Server [closed]

asked by 12.04.2017 / 01:39
2
answers

Bhaskara beginner

When I compile this code, it appears: a1 vale NaN(Não é um número) and then: a2 vale NaN(Não é um número) , follow the code: private void button1_Click(object sender, EventArgs e) { int a = 2; int b = 3; int c = 5;...
asked by 06.03.2018 / 21:06