C#

93K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm converting a System.Array to a list.  Reason I'm doing this is because I can't check the values I want with _excelvalues[1,5].
System.Array excelvalues = (System.Array)_excelsheet.get_Range("A" + index.ToString(), 
    "K" + index.ToString()).Cells.Value;

Open in new window

var values = excelvalues.OfType<object>().Select(o => o.ToString()).ToList();

Open in new window

How do I convert BUT migrate everything from the System.Array to the list.  If it is empty the length of the List does not match the System.Array and I want it to always match.

Example:
System.Array[1,12] -> List[12]

Right now I can get System.Array[1,12] -> List[6]
0
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I am displaying users and file system rights in a list box using C#. It's a desktop application. My current code looks like this:
private void GetFileUsers(string filename)
{
FileSecurity security = File.GetAccessControl(filename);
AuthorizationRuleCollection acl = security.GetAccessRules(true, true, typeof(System.Security.Prinicpal.NTAccount));

foreach (FileSystemAccessRule ace in acl)
{
	string ruleValue = ace.IdentityReference.Value;
	{
		lstSelectedFilePerms.Items.Add(string.Format("{0} - {1}", ace.IdentityReference.Value, ace.FileSystemRights.Equals(FileSystemRights.FullControl) ? "Read,Write" : 		ace.FileSystemRights.ToString()));
	}
}

}

Open in new window


It shows users in a list looking like this:
ABC\john.smith - Read, Write, Synchronize
ABC\mike.jones - Read, Synchronize

I want to do 2 things. Remove the doman and slash, so it just shows the name. And remove Synchronize. Synchronize displays whenever I assign read or write. But I do not wnat to display it. I've got help in similar questions up here. Hoping for help with this one, too. Thank you.
0
I'm having a Null Reference Exception problem when performing simple calculation using C# and WPF.  My main form has a button that brings up an on screen keypad where a number is entered and then returns the number to the respective text boxes, grossLbsTextBox and tareLbsTextBox.  This code worked fine when I used Winforms, but will not work as WPF.  I'm new to C# so I'm sure it's something simple.  Here is the code.  I indicated the line where the exception is thrown.  Thank you!
 public string strLbsEntered;
        private void btnGrossLbs_Click(object sender, RoutedEventArgs e)
        {
            using (NumberPad formObject = new NumberPad())
            {
                formObject.ShowDialog();
                string strLbsEntered = formObject.StrLbsEntered;
                grossLbsTextBox.Text = strLbsEntered;
            }
        }
        public string strTareLbs;
        private void btnTareLbs_Click(object sender, RoutedEventArgs e)
        {
            using (NumberPad formObject = new NumberPad())
            {
                formObject.ShowDialog();
                string strLbsEntered = formObject.StrLbsEntered;
                tareLbsTextBox.Text = strLbsEntered;
            }
        }
        
        private void grossLbsTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            grossLbsTextBox.TextChanged += onChanged;
            //EXCEPTION THROWN HERE>>> tareLbsTextBox.TextChanged += onChanged;
            

Open in new window

0
Hi,

I am using multiple tab pages and each tab will have many controls.

Except few contols (textbox1 and radiobutton1), remaining controls should get disabled in tab page1.

How to do this in windows c#..?
0
i have a very simple project to show all of the rental cars in one single company location. But the issue is I want to show all of the rental cars like 50 vehicles on the map.
However, the location is the same. How can I show them on the map? If I just use same location, the car icon will basically overlap each other.
i use c#, mvc, and razor.
0
It's about exe whose code is written in C#.
I have some text in form in English and Japanese which i want to be appeared in bold language the problem is in Windows 7 both Japanese and English text are coming properly in bold but in Windows 10 only English text is coming in bold, Japanese text is not coming in bold tried Anti-alias property of text, changed font-name to MS Gothic and  Meiryo for Japanese but nothing worked. Any help would be really appreciated.
0
https://developers.google.com/places/web-service/search

I want to use above API to get place = 'rv_park' and my question is if I want to get place type = 'rv_park' in california only.
how can i do that? Basically, I just do not know how to filter by state. I use mvc/c#/razor.

Thank you for your helps in advance.
0
Writing an app that will parse an excel file.  The file has 2 worksheets.  For this purpose say SheetA and SheetB.  I am viewing the process while it is running to see the results.  I want SheetB to displayed in the foreground.  

Any idea how to accomplish?
0
I am trying to extract text from a PDF using iTextsharp library. I've implemented the IRenderListener listener and call PdfReaderContentParse.ProcessContent() to parse:
reader = new PdfReader( in_file );
XMLRenderListener listener = new XMLRenderListener();
PdfReaderContentParser parser = new PdfReaderContentParser( reader );
parser.ProcessContent( page_num, listener );

Open in new window

When the listener's RenderText( TextRenderInfo renderInfo ) method is called, usually the renderInfo.string contains correct text, but not always. For an example, a PDF contains the following symbols:Characters in PDFWhen the method is called, the structure contains the following:
renderInfo content on the symbol 'less than' It is not clear from the picture above, but the PdfString.value actually contains two characters:Invisible characters in renderInfo.PdfString.value
I tried to copy the character from Adobe Reader to the clipboard, and analyzed by Clipboard Viewer.
The "Text" part shows the same bytes:ClipboardViewer Text part, but the Unicode Text Format part shows the correct Unicode value of the character, which is 2266 ClipboardViewer Unicode Text Format part
Also, if I paste that clipboard content to a text editor, I can see the correct character with the code 2266.

The question now: is it possible to make iTextsharp also convert the symbol to correct Unicode value and how to achieve that?
0
Hi All,
Advance thanks for the great solution!
Am using Visual studio 2017 ,c#, MVC. I need to use electronic signature in the .csthml page. I was given strict protocol to follow like not to adapt any third party. i need to capture the signature and display at end of the .cstml page.Please help me or guide me how to do that please...

Kind regards,
Pooja
0
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hi,

I am using Windows C# application which contains many tab.

i want to hide soe of the Tab based on user roles and privileges.

i used below code. but, it is not working..

string title = "Employee DETAILS";
TabPage myTabPage = new TabPage(title);
Tab3.TabPages.Remove(myTabPage);  


When i ran the application, still the "Employee Details" tab are visible...?

what is the problem in the above code.
0
I have this code which I’m using with the attached file and was wondering why the last line (immediately below) is returning a casting error
List<LafAmend> Result = Codes.Where(i => i.Name.Substring(0, 1) == "H");

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp1
{
    public delegate bool CodeCaller(LafAmend lafamend);

    class Program

    {
        static List<LafAmend> Codes = new List<LafAmend>();

        //static bool MyTest(LafAmend lafAmend)
        //{
        //    int test;
        //    return (lafAmend.Name.Substring(0, 1) == "H" && (int.TryParse(lafAmend.INDG, out test)));

        //}
        static List<LafAmend> Where(List<LafAmend> splodge, CodeCaller del)//variable name not important
        {
            List<LafAmend> output = new List<LafAmend>();
            foreach (LafAmend l in Codes)
            {
                if (del.Invoke(l))
                {
                    output.Add(l);
                }
            }
            return output;
        }
        static void Main(string[] args)
        {
            

            string line2 = "";

            foreach (var line in File.ReadAllLines("/Documents/Courses/CSharpQA/Labs/09  DelegatesAndLambdas/Test/Test.csv"))
            {
                line2 = line.Replace(@"""", "");
                string[] Row = line2.Split(',');
                Codes.Add(new LafAmend
               

Open in new window

0
Is SOLID Outdated?

What are more modern definitions/terms for design principles for OOP?

Thanks
1
I need to sort a foreach statement in an MVC website. I've included the code below. I would like to order the results by item.InteractionDate. I believe it is sorting by the Id rather than the InteractionDate. If you need a snippet from the model, I can add that as well.

<table class="table">
        <tr>
            <th>
                Meeting Date
            </th>
            <th>
                Customer
            </th>
            <th>
                Employee
            </th>
            <th>
                Notes
            </th>
            <th>
                Update Meeting
            </th>
        </tr>

        @foreach (var item in Model.Meetings)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.InteractionDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Customer1.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee1.FullName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Notes)
                </td>
                <td>
                    @Html.ActionLink("Edit Meeting", "Edit", "Meetings", new { id = Model.Id}, null)
                </td>
            </tr>
        }
    </table>

Open in new window

0
With C#, how can I check to see if a particular Active Directory group has permissions on a file? So I want to check if DataStewards has read or write access on specific file. If so, enable a button. If not, disable the button. Thanks for any help.
0
Heads-up: Though its little tricky to explain my scenario i will still try my best to explain as clearly as possible.

I have 4 RadGrids(with Column Picker for each RadGrid) on same page & switching between Radgrids doesnt load the current RadGrid name when looking in view source. Though the Data is loaded for different RadGrids.
Issue is with Column Picker.

Requirement: On Change of a RadComboBox List value a different RadGrid has to loaded. Each RadGrid has a COlumn Picker too.
Column Picker -> (list of columns in RadGrid is bided on serverside to a RadListBox and shown in a RadWindow invoked using Javascript )

Basically i have 4 RadGrids(RadGrid1 through RadGrid4) each of which has CommandIteamTemplate -> & asp:LinkButton OnClientClick opens a RadWindow with list of RadGRid Columns whose Display value is True.
Also these 4 RadGrids are 4 seperate user controls with their own unique Javascript methods and Radwindows.

But When ever i chaneg my RAdCombobox value though a different RadGrid is loaded ... Column Picker still shows from the previous RadGrid. At this moment when i look at the view source it still shows previous RadGrid name with java script methods from the same previous RadGrid.

Example: On my Main Page,
Step 1: on page load, RadGrid1 from first user control is loaded with Column picker1 - which was loaded using Javascript1.
sample code in CommandTemplateItem.. <asp:LinkButton ID="lbtnCP" runat="server" …
0
When I compile someone c# code, I got the following warning.  What do I need to resolve this? Any idea?

The primary reference "xxxConfiguration" could not be resolved because it has an indirect dependency on the assembly "xxxAsync, Version=7.05.101.0, Culture=neutral, PublicKeyToken=58aa7495915e0000" which was built against the ".NETFramework,Version=v4.6" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
0
Hi, I.'m trying to set up the zoom of an image ,inside a canvas,  to the value of the ribbon menu item selected.
How can I achieve this?

                 ...
                    <RibbonMenuButton Label="Zoom">
                        <RibbonMenuItem Header="25%"/>
                        <RibbonMenuItem Header="50%"/>
                        <RibbonMenuItem Header="75%"/>
                        <RibbonMenuItem Header="100%"/>
                    </RibbonMenuButton>

...

               <ScrollViewer x:Name="scr_Img" Grid.Column="2">
                    <Canvas x:Name="cnv"  Grid.Column="2" Background="Gray">
                        <Grid Width="{Binding ActualWidth, ElementName=cnv_marking}" Height="{Binding ActualHeight, ElementName=cnv}">
                            <Image x:Name="img_Zoom" 
                                SizeChanged="img_Zoom_SizeChanged"
                                MouseDown="img_Zoom_MouseDown" MouseLeftButtonDown="img_Zoom_MouseLeftButtonDown"
                                Height="{Binding ActualHeight, ElementName=cnv}"/>
                        </Grid>
                    </Canvas>
                  </ScrollViewer>

Open in new window

0
Hi.
I created an folder in project directory (see the attached pic) .
Into this folder I will save some files while user use the program. When program close those file will be removed.
I'm programming in C# WPF.
The problem is that I cannot add files to this folder and get message:
'Could not find a part of the path 'E:\GAB-SW\Program\Source Code\Program_WPF\Program_WPF\bin\Debug\temp\Profile174.png'.'
If I open the project folder my "temp" folder was exist there.
Which path I have to use to save my files in this folder?
Capture1.PNG
Capture.PNG
0
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

The codes below is extracted from mvc razor view page / c#.
My question is how to pass pair name/value back  to mvc controller.

Thanks,


<script>
        function Validator() {
            return true;
        }
        function UpdateEventCost() {
            if (Validator() == true) {
                var totalCount = document.getElementById("totalcount").value;
                alert("Success");
                var inputs = document.getElementsByTagName("input");
                for(x=0; x<=inputs.length;x++)
                {
                    var id_name = inputs[x].getAttribute("id");
                    var id_value = document.getElementById(id_name).value;
                }
                //window.location.href = "/Home/MotorhomeEdit/15";
            }
            else {
                alert("Error");
            }
        }
</script>

Open in new window

0
I am writing an app that will get a list of directories and files.  I am populating a List<string> to store this information.

I created an ENUM to determine what directories and file extensions should be excluded.  I was trying to figure out how to write linq to "removeall" from the list against the values in the ENUM.  

Want to see if there is a way without looping through each value in List<string>.
public static class Enumerators
{
	public enum ExcludedDirectories
	{
		ABC
	}

	public enum ExcludedFiles
	{
		docx,
		Thumbs
	}
}

Open in new window

My solution is below.
    public static class EnumValidation
    {
        public static List<string> DeleteValues<T>(List<string> value)
        {
            var deletionvalues = Enum.GetValues(typeof(T));

            foreach (var del in deletionvalues)
            {
                value.RemoveAll(x => x.Contains(del.ToString()));
            }

            return value;
        }
    }

Open in new window

Is there a more efficient way?
0
I am working on an application that talks to 3rd party API, the API access gets locked out for every n requests but the API is not responding with an appropriate error message saying the account is locked out, and also now they are not ready make any changes to the API to send an user friendly message. We are getting some common weird message whenever account is locked out based on which we are understanding that the account is locked

are there any best practices to handle these kind of lock out mechanisms in C# Windows Service for the API calls?, I wanted to log message that the account is locked out and the password has to be reset and also to send an email
0
Hi,

i am using Windows application.

my client want to set password in MS Access DB.

When end user selecting the file from browse button, system should check the password and set password somewhere in the application.

if the set password and Access password is match then system allow further process.

How to do this in Windows C# applications.?
0
How to read Child tags under parent tag with name space in C#?
<ns:tag1></ns tag1>
<ns:tag2>
<child1></child1>
<child2></child2>
</ns:tag2>

How to read child 1 tag?
I am able to till ns:tag2 but unable to read any further tag.
var child = parentElement.Descendants(ns + "tags").First();
This provides list of child tags, but unable to further read it.
Tried a few things like:
child.Descendants("child1").First().Value
and child.Element("child1") (with all possible sub functions)
etc
Even tried to reload the xml from tag2 in XElement again but that threw invalid xml exception.
but all are throwing null pointer exceptions.
0
Hi guys,

I am curious about the benefits of using SDKs. Personally, I prefer avoiding third-party libraries, especially if I don’t see any benefits of having serialized JSON output in class models (I have found this to be the case when using JavaScript, NodeJS, PHP, Python, and other functional programming languages). When using serialized JSON models in Java, C++, C#, and ActionScript, I observed a decline in performance.

However, I am aware that companies including Google, Amazon, Salesforce, etc are generating REST API services for SDK code for developers to consume.
 
What have you found to be the main pros/cons of using SDK, and what are your personal preferences regarding which REST SDK is best for various languages?

Best,
David
0

C#

93K

Solutions

25K

Contributors

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).