DROP A DRACO
Explore posts from servers✅ text document boring thing but i'm stuck >_<
c#
// Helper function to convert text inside double quotes to lowercase
private static string ConvertToLowerCaseInsideQuotes(string text)
{
int startQuoteIndex = text.IndexOf('"');
int endQuoteIndex = text.LastIndexOf('"');
if (startQuoteIndex >= 0 && endQuoteIndex >= 0 && startQuoteIndex < endQuoteIndex)
{
string insideQuotes = text.Substring(startQuoteIndex, endQuoteIndex - startQuoteIndex + 1);
string lowercaseInsideQuotes = insideQuotes.ToLower();
return text.Substring(0, startQuoteIndex) + lowercaseInsideQuotes + text.Substring(endQuoteIndex + 1);
}
return text;
}
}
c#
// Helper function to convert text inside double quotes to lowercase
private static string ConvertToLowerCaseInsideQuotes(string text)
{
int startQuoteIndex = text.IndexOf('"');
int endQuoteIndex = text.LastIndexOf('"');
if (startQuoteIndex >= 0 && endQuoteIndex >= 0 && startQuoteIndex < endQuoteIndex)
{
string insideQuotes = text.Substring(startQuoteIndex, endQuoteIndex - startQuoteIndex + 1);
string lowercaseInsideQuotes = insideQuotes.ToLower();
return text.Substring(0, startQuoteIndex) + lowercaseInsideQuotes + text.Substring(endQuoteIndex + 1);
}
return text;
}
}
10 replies
✅ text document boring thing but i'm stuck >_<
c#
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
// Define the input and output file paths
string inputFile = "input.txt";
string outputFile = "output.txt";
// Read the input file
string[] lines = File.ReadAllLines(inputFile);
// Process and write to the output file
using (StreamWriter writer = new StreamWriter(outputFile))
{
foreach (string line in lines)
{
// Split the line based on the first occurrence of a double quote
int firstQuoteIndex = line.IndexOf('"');
if (firstQuoteIndex >= 0)
{
string firstPart = line.Substring(0, firstQuoteIndex);
string secondPart = line.Substring(firstQuoteIndex);
// Convert the second part (inside double quotes) to lowercase
string modifiedSecondPart = ConvertToLowerCaseInsideQuotes(secondPart);
// Combine the first part and the modified second part
string modifiedLine = firstPart + modifiedSecondPart;
// Write the modified line to the output file
writer.WriteLine(modifiedLine);
}
else
{
// If there's no double quote, write the line as is
writer.WriteLine(line);
}
}
}
Console.WriteLine("Conversion completed. Check the output file for the result.");
}
c#
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
// Define the input and output file paths
string inputFile = "input.txt";
string outputFile = "output.txt";
// Read the input file
string[] lines = File.ReadAllLines(inputFile);
// Process and write to the output file
using (StreamWriter writer = new StreamWriter(outputFile))
{
foreach (string line in lines)
{
// Split the line based on the first occurrence of a double quote
int firstQuoteIndex = line.IndexOf('"');
if (firstQuoteIndex >= 0)
{
string firstPart = line.Substring(0, firstQuoteIndex);
string secondPart = line.Substring(firstQuoteIndex);
// Convert the second part (inside double quotes) to lowercase
string modifiedSecondPart = ConvertToLowerCaseInsideQuotes(secondPart);
// Combine the first part and the modified second part
string modifiedLine = firstPart + modifiedSecondPart;
// Write the modified line to the output file
writer.WriteLine(modifiedLine);
}
else
{
// If there's no double quote, write the line as is
writer.WriteLine(line);
}
}
}
Console.WriteLine("Conversion completed. Check the output file for the result.");
}
10 replies